Upload image on server does not work

2

When I upload locally using WAMP64, everything happens normally. However, when I upload from the site, which is on the production server, the following error message is displayed.

  

NoWritableException in Image.php line 143:

     

Can not write image data to path (/home/premiumcarstudio/laravel/public/1481746280.jpeg)

CodethatI'mtryingtousetoupload

if($request->hasFile('fileUpload')){$image=$request->file('fileUpload');$filename=time().'.'.$image->getClientOriginalExtension();$path=public_path('images/ImagensPosts/'.$filename);Image::make($image->getRealPath())->resize(570,350)->save(public_path($filename));$post->imagem='images/ImagensPosts/'.$filename;}$post->save();

OBS.Ihavealreadychangedtheaccesspermissionstotheimagedirectoryontheserver.

DirectoryonServer

    
asked by anonymous 14.12.2016 / 21:17

1 answer

0

In Laravel 5.3 , the recommended standard is to save to the storage / app folder, which already has permission to write. Usually I use:

$request->nome_do_campo_do_arquivo->storeAs('pasta_de_destino', 'nome_do_arquivo.ext')

This creates the destination folder (if it does not exist) and gives the file a new name.

If you are using previous versions, try giving write permission to the public / folder. I hope I have helped.

To view the documentation, click here .

    
15.12.2016 / 13:50