I am trying to upload an image in Laravel. Getting the following error:
"message": "Could not move the file "C:\xampp\tmp\php84AA.tmp" to "F:\bvend\bvend-web\public\uploads/products\bvend-product-1666274539.jpg" (move_uploaded_file(): Unable to move "C:\xampp\tmp\php84AA.tmp" to "F:\bvend\bvend-web\public\uploads/products\bvend-product-1666274539.jpg").",
"exception": "Symfony\Component\HttpFoundation\File\Exception\FileException",
"file": "F:\bvend\bvend-web\vendor\symfony\http-foundation\File\UploadedFile.php",
"line": 177,
"trace": [ .... ]
My code is given below:
public function uploadImage($image, $image_path)
{
$path = config('global.' . $image_path . '_image_path');
file_exists($image) && unlink($image);
$image_name = 'bvend-' . $image_path . '-' . time() . '.' . $image->getClientOriginalExtension();
$image->move($path, $image_name); // $path: public_path('uploads/products')
return $image_name;
}
I understand its a simple issue but still no clue where it causing issue.
2
Answers
I am using this methodology in Laravel 9.
try this:
Edit
Specifying A File Name
Solution
Addendum
Don’t forget to create a symbolic link from
public/storage
tostorage/app/public
. I.e:php artisan storage:link
.The Public Disk
In Summary