Jump to content

Recommended Posts

Hello.

I have a code that should prompt for a zip file download.

 

header("Content-Type: application/zip");
header('Content-length:'.filesize('zips/'.$_REQUEST['listing_id'].'.zip'));
readfile('blabla.zip');

 

It works OK but the problem is that I have to add session_start() right before that code, to check some user properties.

When I do this I get "corrupted zip file" error in browser.

 

Is it wrong to add session_start() with zip header info? Maybe there is some known issue?

Thank you.

Can you post more of you code? ... session_start(); shouldn't corrupt the file.

I simplified it as much as I could removing db queries, this gives an error:

 

if(isset($_REQUEST['file_to_get']) and $_REQUEST['file_to_get']!=''){
session_start();
header("Content-Type: application/zip");
header('Content-length:'.filesize('temp_zips/'.$_REQUEST['file_to_get']));
header("Content-Disposition: attachment; filename=".$_REQUEST['file_to_get']);
readfile('temp_zips/'.$_REQUEST['file_to_get']);
unlink('temp_zips/'.$_REQUEST['file_to_get']);
exit;
}
?>

 

Just adding session_start() there shows me this error:

 

1387_600x400.jpg

 

Maybe I should add some encoding header information?

I looked with notepad and first characters appear to be pczip something (the library that creates the zip) but I dont see any errors.

I attached that zip if you want to look but I think there is nothing helpfull.

 

This happens in InternetExplorer only, if I chose directly "open" at download prompt.

If I chose "save" then after download completed I chose "open" it works fine.

 

[attachment deleted by admin]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.