0
my web directory is at ip 192.168.120.3 , when I upload an image, I want the image to be stored in a different folder from my web directory, for example saved at ip 192.168.120.4, how do I do that?

This is my code :

$newname = $getFileName."-".date('YmdHis',time()).mt_rand().'.jpg';
$target =  '\\\\192.168.164.5\\Common Pict\\'.$newname;
$tmp = $val['tmp_name'];
                                    
move_uploaded_file($tmp, $target);

Error :

move_uploaded_file(\192.168.164.5\Common Pict\m-20221206105651907307421.jpg): failed to open stream: Invalid argument

Code working if i upload an image to web directory:

$newname = $getFileName."-".date('YmdHis',time()).mt_rand().'.jpg';
$target =  '\\\\192.168.120.3\\Common Pict\\'.$newname;
$tmp = $val['tmp_name'];
                                    
move_uploaded_file($tmp, $target);
  • 4
    `move_uploaded_file` expects a path, not an ip address. A path such as `C:\name\somewhere` or `/home/user/somewhere`. – Jesse Dec 06 '22 at 04:19
  • Don't use code block (```) for style your question. – vee Dec 06 '22 at 04:25
  • 1
    ["mount" your network drive](https://stackoverflow.com/questions/66463728/how-to-map-a-network-share-folder-to-a-local-folder-in-windows-without-additiona) on a folder so `php` can see it as a "normal" folder. also, make sure you have write access. – Bagus Tesa Dec 06 '22 at 05:52
  • Alternatively you could use FTP to move the file from the server to the networkshare – DarkBee Dec 06 '22 at 06:20

0 Answers0