Reputation: 13
I'm trying to upload some pictures from others websites using Symfony Messenger.
I'm using a service I built to retrieve picture from a URL and I have this portion of code:
$name = substr($url, strrpos($url, '?') + 1);
$path = 'uploads/' . $name;
$file = fopen($path, 'w+');
fputs($file, $content);
fclose($file);
As you can guess the "uploads" folder is in my "public" folder.
I tested my code from a controller and it works perfectly.
Now when I run the same code from the "RetrieveImageHandler" it return the error :
ErrorException: Warning: fopen(public/uploads/myImage.jpg): Failed to open stream: No such file or directory in C:\wamp64\www\myproject\src\Service\getImageService.php:86
I understand I should use another path to find my public folder but I don't know which one.
Which path should I use?
Upvotes: 1
Views: 22