Trying to build a form where for uploading images via url and have it copied from there to my server.
Searching the follwoing threads:
- Copy Image from Remote Server Over HTTP
- Copy file from remote server or URL
- How to copy a remote image to my website directory?
I've tried this:
$pic = Submitted image URL
$pic = Submitted image name . ".jpg"
copy($pic, $_SERVER['DOCUMENT_ROOT'] . '/mydir/' . $picname);
Results in:
Warning: copy(mydir/mypic.jpg) [function.copy]: failed to open stream: No such file or directory in /home/user/public_html/mysite.ca/upload.php on line 42
This:
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . '/mydir/' . $picname, "w");
fwrite($fp, $pic);
fclose($fp);
Results in:
Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/user/public_html/mysite.ca/upload.php on line 47
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/user/public_html/mysite.ca/upload.php on line 48
Directory permissions are 777, their is no personal info anywhere on the server. There is no error in any of the logs, I'm not sure how to troubleshoot this?