Problem in files after upload, in Laravel 5.4

0

I have the following code to upload files in my Laravel application.

upload.blade

<div class="form-group">
 <label for="name" class="col-sm-3 control-label">Documento *:</label>
    <div class="col-sm-6">
        <input  type="file" multiplename="docs[]"/>
    </div>
</div>

DocumentsController

public function move(Request $request)
{

    if ($request->hasFile('docs')) {

        $doc = $request->file('docs');


        foreach($doc as $files)
        {

            //Recupera o nome original do arquivo
            $filename  = $files->getClientOriginalName();

            //Recupera a extensão do arquivo
            $extension = $files->getClientOriginalExtension();

            //Definindo um nome unico para o arquivo
            $name  = $filename . '.' . $extension;

            //Diretório onde será salvo os arquivos
            $destinationPath = storage_path('documents');

            //Move o arquivo para a pasta indicada
            $files->move($destinationPath, $name);
        }


        Session::flash('flash_message_success', 'Documento carregado com sucesso!');
        return redirect()->action('DocumentsController@upload');
    }
    else
    {
        Session::flash('flash_message_error', 'Arquivo não carregado. Tente novamente!');
        return redirect()->action('DocumentsController@upload');
    }

}

So far so good, the files are uploaded to the destination folder, but you can not open them. Below the jpeg files error and I also get the error in PDF.

Any suggestions?

    
asked by anonymous 12.07.2017 / 01:29

0 answers