Here is the code snippet:
public function uploadPhoto(){
$filename = '../storage/temp/image.jpg';
file_put_contents($filename,file_get_contents('http://example.com/image.jpg'));
$photoService->uploadPhoto($filename);
echo("If file exists: ".file_exists($filename));
unlink($filename);
}
I am trying to do the following:
- Get the photo from the URL and save it in a temporary folder on my server. It works great. An image file is created and echoed
If file exists: 1when echo("If file exists: ".file_exists('../storage/temp/image.jpg'));. - Pass this file to another function that uploads the file to the Amazon s3 trash. The file is stored in my s3 statement.
- Delete the photo saved in the temp folder. This does not work! I get an error message:
unlink (../storage/temp/image.jpg): the resource is temporarily unavailable
If I use rename($filename,'../storage/temp/renimage.jpg');instead unlink($filename);, I get an error:
rename (../storage/temp/image.jpg,../storage/temp/renimage.jpg): , . (: 32)
$photoService->uploadPhoto($filename);, .
, , - ? .
, ! .