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

tehseen's avatar

ZIp upload fine but download issue.

I have write below code to upload zip however its fine to upload product in folder, But when i download via link the file type change and its no longer useful.

Here is the code to upload zip file

if($request->hasFile('product_zip')) {
            $zip = $request->file('product_zip');
            $filename_zip = time().'-'.uniqid().'-'.$zip->getClientOriginalExtension();
            $location = public_path('zip');
            $zip->move($location, $filename_zip);
            $product->product_zip = $filename_zip;
        } else {
            $product->product_zip = "";
        }
           	

Here is the validation

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

Thanks for help in advance

0 likes
7 replies
Sinnbeck's avatar

If the issue is with download, can you post some information about how you do that part?

tehseen's avatar

@sinnbeck thanks for reply.

So we have product zip folder where we save name and then we have this below link to download the zip

{{ asset( 'zip/'.$product->product_zip) }}

But i can see in my zip folder the once zip upload the file extension change its no more zip

see the screenshot please https://ibb.co/54yn5f2

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Yes you have a - instead of .

            $filename_zip = time().'-'.uniqid().'.'.$zip->getClientOriginalExtension();

Please or to participate in this conversation.