Save remote Picture code do not know how to modify the save path wait for the master advice
//
Function: Get the remote picture and save it locally
//
//
Make sure you have permission to write files to the local server
//
//
Variable Description:
$url is the full URL address of the remote picture and cannot be empty.
$filename is an optional variable: If blank, the local file name will be based on the time and date
Automatically generated.
function Grabimage ($url, $filename = "") {
PHP Programmer Station
if ($url = = ""): return false;endif;
if ($filename = = "") {
$ext =STRRCHR ($url, ".");
if ($ext! = ". gif" && $ext! = ". jpg"): return false;endif; Phperz.com
$filename =date ("Dmyhis"). $ext;
}
Ob_start ();
ReadFile ($url);
$img = Ob_get_contents ();
Ob_end_clean ();
$size = strlen ($img);
Www.phperz.com
[Email protected] ($filename, "a");
Fwrite ($fp 2, $img);
Fclose ($fp 2);
return $filename;
}
$img =grabimage ("Http://www.ljj.com/d/untitled.jpg", "" ");
PHP Programmer Station
if ($img): Echo '
';
Else:echo "false";
endif
?>
Download area found code do not know how to modify after you can save the attachment to the specified directory, please expert advice
------Solution--------------------
Don't change the code. For example you call this: $img =grabimage ("Http://www.ljj.com/d/untitled.jpg", "./test/aa.png");
will be saved to the test directory, named Aa.png. Of course you pass the directory to exist.