php - Copy image from URL to Web Server File System -


trying build form uploading images via url , have copied there server.

searching follwoing threads:

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

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -