ThanhPv's avatar

Excel saved as bin

Hi, I am having problem that when uploading excel file it always save to .bin file

 protected function upload() {
       
        $file = $this->file('file');
        $extension = $file->extension();        

        $path = storage_path('forms');
        $name = 'F_'.$this->input('code');
        $name = $name.'.'.$extension;       
        $file->move($path, $name);      
        $path = $path.'/'.$name;

        return $path;
     
    }

Please help?

0 likes
1 reply
timargv's avatar
$file = $this->file('file');

$fileHash = str_replace('.' . $file->extension(), '', $file->hashName());
$fileName = $fileHash . '.' . $file->getClientOriginalExtension();

$path = \Storage::disk('public')->putFileAs('forms/files', $file, $fileName),

Please or to participate in this conversation.