How are you uploading it? What is your dev setup? Windows? Php artisan serve?
Jun 27, 2022
7
Level 1
Laravel don't accept .xlsx file uploads
When i try to upload image or some other file and do dd($request->all()) i get:
array:2 [
"scanName" => "lt"
"file" => Illuminate\Http\UploadedFile {#1419
-test: false
-originalName: "lt.png"
-mimeType: "image/png"
-error: 0
#hashName: null
path: "C:\wamp64\tmp"
filename: "phpC43B.tmp"
basename: "phpC43B.tmp"
pathname: "C:\wamp64\tmp\phpC43B.tmp"
extension: "tmp"
realPath: "C:\wamp64\tmp\phpC43B.tmp"
aTime: 2022-06-27 17:22:33
mTime: 2022-06-27 17:22:33
cTime: 2022-06-27 17:22:33
inode: 23643898043891995
size: 928
perms: 0100666
owner: 0
group: 0
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
linkTarget: "C:\wamp64\tmp\phpC43B.tmp"
}
]
it is all good here, but when i try to upload .xlsx file this is the result
array:2 [
"scanName" => "RMAREU-2205-017"
"file" => Illuminate\Http\UploadedFile {#1419
-test: false
-originalName: "RMAREU-2205-017.xlsx"
-mimeType: "application/octet-stream"
-error: 1
#hashName: null
path: ""
filename: ""
basename: ""
pathname: ""
extension: ""
realPath: "C:\Users\remig\PhpstormProjects\teamworx\public"
aTime: 1970-01-01 03:00:00
mTime: 1970-01-01 03:00:00
cTime: 1970-01-01 03:00:00
inode: false
size: false
perms: 00
owner: false
group: false
type: false
writable: false
readable: false
executable: false
file: false
dir: false
link: false
}
]
validation looks like this
public function rules()
{
return [
//'file' => 'required',
'scanName' => 'required|string'
];
}
and when i uncomment file field and upload .xlsx file i get this validation error.
XHRPOSThttp://teamworx.local/createNewItemScan
[HTTP/1.1 422 Unprocessable Content 399ms]
message "The given data was invalid."
errors Object { file: […] }
file [ "The file failed to upload." ]
0 "The file failed to upload."
Level 51
Increase you file size limit in php.ini
Please or to participate in this conversation.