ERROR WHILE UPLOADING Laravel

Asked

Viewed 77 times

-1

Sirs,

I am having the following error "The "/tmp/php63F4kk" file does not exist or is not readable." in Laravel, I am entering the information as follows:

if($request->hasfile('foto'))
     {

            $image = $request->file('foto');
            $name = $image->getClientOriginalExtension();
            $fileName = time() . '.' . $name; 
            $image->move(public_path().'/fotos/sobre/', $fileName);  
            $data = $fileName;  

     }

    $sobre = new SobreDestino();

    $sobre->destino_id = $request->id_destino;
    $sobre->descricao = $request->sobre;
    $sobre->titulo = $request->titulo_foto;
    $sobre->foto = $data;
    $sobre->save();

Where can I be missing?

Thank you

1 answer

1


Change the first part:

$extension = $request->file('foto')->getClientOriginalExtension();     
$name = uniqid();
//salva um nome baseado no id
$nameFile = $name.'.'.$extension; 
$path = $request->file('imagem')->storeAs('fotos/sobre/',$nameFile,local)); 

And that stretch:

$sobre->foto = 'storage/fotos/sobre/'.$nameFile;

Then run in command:

php artisan storage:link

With this you will make the uploads in the application’s Storage and will have a symbolic link in the application’s public. This is the way described in the documentation! I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.