1 month ago

ZIp upload fine but download issue.

Posted 1 month ago by tehseen

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

Please sign in or create an account to participate in this conversation.