In Laravel 5.5 project, I have successfully saved the info into product table in MySQL. The info include a base64 string which is an image basically. However, I'm facing an issue while stroing the image in public folder of the laravel project. Below is my code for the ProductController.php
public function update(Request $request, $id)
{
$data = $request->validate([
'product_name' => 'required',
'description' => 'required',
'rating' => 'required'
]);
$uploaded_image = $request->input('uploaded_image');
$data['uploaded_image'] = $uploaded_image['value']; // base64 string
$product = Product::findOrFail($id);
$product->update($data);
// the data stored into the database with no issue
$image_base64 = base64_decode($uploaded_image['value']);
$path = public_path();
$success = file_put_contents($path, $image_base64.".png");
return response()->json($data);
}
I see the following error below:
message:"file_put_contents(C:\xampp\htdocs\laravel-api\public): failed to open stream: Permission denied"
By seeing different sources, I did the following, but nothing changed.
- php artisan clear-compiled
- Icacls public /grant Everyone:F
- composer dump-autoload
Any idea?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire