php - Copy image from URL to Web Server File System -
trying build form uploading images via url , have copied there server.
searching follwoing threads:
- copy image remote server on http
- copy file remote server or url
- how copy remote image 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 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 resource, boolean given in /home/user/public_html/mysite.ca/upload.php on line 47
warning: fclose() expects parameter 1 resource, boolean given in /home/user/public_html/mysite.ca/upload.php on line 48
directory permissions 777, no personal info anywhere on server. there no error in of logs, i'm not sure how troubleshoot this?
directly opening urls files works if server has allow_url_fopen
option enabled.
fopen()
failing , returning false
not checking that. there wrong filename or directory permissions.
Comments
Post a Comment