i need to be able to save an image from a url to my server. i am creating a movie search app which uses the amazon api to search for an entered dvd and then save all the info to a database and as part of that i want to save the cover art to my server.
i tried using the following code which i found on the web but it doesnt really work.
$url_file = fopen($myImageURL,'rb');
$newfile_name = "/" . $myUPC . ".jpg";
$newfile = fopen($newfile_name,'wb');
while (!feof($url_file)) {
$chunk = fread($url_file,1024);
fwrite($newfile,$chunk);
}
fclose($newfile);
fclose($url_file);
i get the following error wheni try and run it:
Warning: fopen(/097368884144.jpg) [function.fopen]: failed to open stream: Permission denied in C:\MovielistSite\backend\addmovie2.php on line 39
Warning: fwrite(): supplied argument is not a valid stream resource in C:\MovielistSite\backend\addmovie2.php on line 42
Warning: fwrite(): supplied argument is not a valid stream resource in C:\MovielistSite\backend\addmovie2.php on line 42
Warning: fwrite(): supplied argument is not a valid stream resource in C:\MovielistSite\backend\addmovie2.php on line 42
Warning: fwrite(): supplied argument is not a valid stream resource in C:\MovielistSite\backend\addmovie2.php on line 42
Warning: fwrite(): supplied argument is not a valid stream resource in C:\MovielistSite\backend\addmovie2.php on line 42
Warning: fwrite(): supplied argument is not a valid stream resource in C:\MovielistSite\backend\addmovie2.php on line 42
Warning: fwrite(): supplied argument is not a valid stream resource in C:\MovielistSite\backend\addmovie2.php on line 42
Warning: fclose(): supplied argument is not a valid stream resource in C:\MovielistSite\backend\addmovie2.php on line 44