I don't know how to modify the save path of the code for saving remote images ;? Php & nbsp; Function: & nbsp; obtain the remote image and save it locally & nbsp; are you sure you have the permission to write files to the local server?
//
// Function: obtain the remote image and save it to the local device.
//
//
// Make sure you have the permission to write files to the local server
//
//
// Variable description:
// $ Url is the complete URL of the remote image. it cannot be blank.
// $ Filename is an optional variable. if it is null, the local file name is based on the time and date.
// Automatically generated.
Function GrabImage ($ url, $ filename = ""){
// Php programmer site
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
$ Fp2 = @ fopen ($ filename, "");
Fwrite ($ fp2, $ img );
Fclose ($ fp2 );
Return $ filename;
}
$ Img = GrabImage ("http://www.ljj.com/d/untitled.jpg ","");
// Php programmer site
If ($ img): echo'
';
Else: echo "false ";
Endif;
?>
The code found in the download area does not know how to modify it. then, you can save the attachment to the specified directory.
------ Solution --------------------
No need to change the code. For example you call: $ img = GrabImage ("http://www.ljj.com/d/untitled.jpg", "./test/aa.png ");
It will be stored in the testdirectory named AA.png. Of course, the directory you pass must exist.