Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tehseen's avatar

Want to upload maximum 20mb zip file.

I want to upload 20mb max file (type zip) i write the following validation

$this->validate($request, [
	'product_zip' => 'required|mimes:zip|size:50000',
]);

i also have zip file which is

+files: FileBag {#47 ▼
#parameters: array:1 [▼
      "product_zip" => UploadedFile {#32 ▼
        -test: false
        -originalName: "stock-icon-bulb.zip"
        -mimeType: "application/x-zip-compressed"
        -size: 16285787
        -error: 0
        path: "C:\xampp\tmp"
        filename: "php8FAF.tmp"
        basename: "php8FAF.tmp"
        pathname: "C:\xampp\tmp\php8FAF.tmp"
        extension: "tmp"
        realPath: "C:\xampp\tmp\php8FAF.tmp"
        aTime: 2020-09-07 10:05:50
        mTime: 2020-09-07 10:05:50
        cTime: 2020-09-07 10:05:50
        inode: 0
        size: 16285787
        perms: 0100666
        owner: 0
        group: 0
        type: "file"
        writable: true
        readable: true
        executable: false
        file: true
        dir: false
        link: false
        linkTarget: "C:\xampp\tmp\php8FAF.tmp"

but it throw me validation error, what was wrong please advice.

0 likes
9 replies
maaz's avatar

try this

'product-zip' => 'required|mimes:zip|max:20000', 
tehseen's avatar

thanks for answer but its 200mb isn't i want to validate file upto 20mb not 200mb

Snapey's avatar

You have to increase php settings for max upload and max post size.

Its also helpful to say what this means

but it throw me validation error,

maaz's avatar

no its 20mb . 1mb = 1024kb so do 20mb will be round about 20000 Mb

tehseen's avatar

Thanks.

So what i write in validation is correct for 20mb ?

tehseen's avatar

Yes i wrote 50000 but still get error with 20mb file.

tehseen's avatar

It means the validation error like below

$this->validate($request, [
	'product_zip' => 'required|mimes:zip|size:20000',
]);

but still get error the file is 16.58mb

tehseen's avatar

this error

The product zip must be 50000 kilobytes.

even file is 16mb you can see here

"product_zip" => UploadedFile {#32 ▼
        -test: false
        -originalName: "stock-icon-bulb.zip"
        -mimeType: "application/x-zip-compressed"
        -size: 16285787
        -error: 0
        path: "C:\xampp\tmp"
        filename: "php8FAF.tmp"
        basename: "php8FAF.tmp"
        pathname: "C:\xampp\tmp\php8FAF.tmp"
        extension: "tmp"
        realPath: "C:\xampp\tmp\php8FAF.tmp"
        aTime: 2020-09-07 10:05:50
        mTime: 2020-09-07 10:05:5

Please or to participate in this conversation.