$filename=~m/^.*(\\|\/)(.*)/; # strip the remote path and keep the filename my ($newfilename) = $1; open(LOCAL, ">/var/www/html/upload/".$newfilename);