I am trying to use Laravel 5's Storage::disk()->putFile() method to upload images to my server. When I use php artisan serve locally, the image uploads successfully to the local disk. When I upload to the server side, it says the file does not exist. I have tried setting the max post and upload size to 20MB, using php artisan storage:link, and using s3 and public instead of the local disk but nothing has seemed to work.
Here is my method:
public function api_create(Request $request)
{
try {
$requestData = $request->all();
$uniqueFileID = Storage::disk('local')->putFile('product_media', new File($requestData["imageCode"]));
$requestData["imageCode"] = $uniqueFileID;
Image::create($requestData);
return "true";
} catch (Exception $exception) {
return "false";
}
}
Here is my error:
local.ERROR: Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException: The file "/Users/drewgallagher/Downloads/download.png" does not exist in /home/52064-43928.cloudwaysapps.com/wrdddnmtvz/public_html/vendor/symfony/http-foundation/File/File.php:37
File does not exist
when my storage folder permissions are wrong. The instructions from user "Bgies" on this page is what I use to fix my permission issues: laracasts.com/discuss/channels/general-discussion/…. Files to 644, and folders to 755 – Hollings