/ Published in: PHP
Expand |
Embed | Plain Text
//original image $img = "http://www.site.com/blah.gif"; //directory to copy to (must be CHMOD to 777) $copydir = "/home/user/public_html/directory/";
Comments
Subscribe to comments
You need to login to post a comment.

$removefile = "http://www.site.com/blah.gif"; $localfile = "./blah.gif";
$data = filegetcontents($removefile); fileputcontents($localfile, $data);
Useful script, but how about stripping the filename and using that instead of blah.gif? like: 3. $fname= basename($img); and replace '8' by:
$file = fopen($copydir . $fname, "w+");
so full code will be:
//original image $img = "http://www.site.com/blah.gif.JPG"; $fname= basename($img); echo $fname; //directory to copy to (must be CHMOD to 777) $copydir = "/var/www/upload/"; $data = filegetcontents($img);
$file = fopen($copydir . $fname, "w+"); fputs($file, $data); fclose($file);
Apparently I have trouble putting the code in properly so here goes again:
//original image $img = "http://www.site.com/blah.gif.JPG"; $fname= basename($img);
//directory to copy to (must be CHMOD to 777) $copydir = "/var/www/upload/"; $data = filegetcontents($img); $file = fopen($copydir . $fname, "w+"); fputs($file, $data); fclose($file);
I apologize but this is the first ever comment I put here and already I am screwing up. Here goes again
//original image
$img = "http://www.site.com/blah.gif";
$fname= basename($img);
//directory to copy to (must be CHMOD to 777)
$copydir = "/var/www/upload/";
$data = filegetcontents($img); $file = fopen($copydir . $fname, "w+");
fputs($file, $data);
fclose($file);