I uploaded this excel file: myExceldocument.xlsx
After uploading I want to store in a folder.
I used this method:
$uploadedFile = $request->file('files')[0]->getClientOriginalName(); //it worked
Excel::store(new DeductionsImport, $uploadedFile, 'documents');
'documents'
is related to filesystem.
The excel file is correctly filed in my folder called 'documents'.
The problem is when I open it, the excel file is empty! Do you know why ?
My goal is only upload an excel document and store in folder.
CodePudding user response:
Excel::store
is for storing exports, not saving uploaded files.
If you are simply trying to save your myExceldocument.xlsx
to your documents folder, the request object has a simple method for it.
// Where 'files' is the name of the upload field in HTML.
$request->file('files')->store('documents');
CodePudding user response:
Voici un autre exemple que j'ai trouvé à partir de la première réponse :
$fileNameToStore = $request->file('files')[0]
Storage::disk('documents')->put($fileNameToStore, fopen($file, 'r '));
work but is not the best solution because folder is filed with '' :
$file->storeAs('',$file->getClientOriginalName(),'documents');