I am having some trouble uploading a file - excel file.
I am using this rule in laravel 5.5 for max file size 3MB. According to the documentation the value must be in KB.
// Max file size: 3MB (3000 KB)
$validator = Validator::make($request->all(), [
'Feed' => 'file|max:3000',
]);
if ($validator->fails()) {
return Redirect::back()->withErrors(['File to big!']);
}
In php.ini i have:
upload_max_filesize=3M
The file which i want to upload is 2.3 MB.
What i did wrong on validation?
UPDATE
Displaying the $_FILES['Feed'] for the file that i want to upload (original.xls = 2.3MB)
array:5 [
"name" => "original.xls"
"type" => ""
"tmp_name" => ""
"error" => 1
"size" => 0
]
"error" => 1
and upload another small file 5.6 KB:
array:5 [
"name" => "test.xls"
"type" => "application/vnd.ms-excel"
"tmp_name" => "/tmp/phpJUJfy4"
"error" => 0
"size" => 5632
]
"error" => 0 and i can see the size for it
UPDATE 2
If i start to delete from the excel file and get max: 2MB, the file uploads with no errors.
Why? 2.0 MB uploads the file and 2.1 MB NOT???