Lisa
Lisa

Reputation: 39

.zip extension missing on download

I have a site which allows clients to download files that they have purchased.

A link is sent to the customer which directs them to a page which checks if the link is valid, and if it is, allows them to download their product.

Here is an example of the link: http://www.psptubestop.com/dl/2z129a2.php?reference=6d556bde201a2fe4079874168&password=535864380ee2bc0f57cced3fe&pid=402

A lot of customers are saying that when they download, the .zip extension is missing, and I can't find the problem, it works fine on my machine, except when I do "save as", but even then some people are having problems.

Is there any way to allow them to download the file, and keep the .zip extension even if they press "save as"?

This is the code I am using to redirect them to the download...

header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$originalfilename");
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");

Thanks for any help.

Upvotes: 0

Views: 872

Answers (3)

Sammitch
Sammitch

Reputation: 32272

I am willing to bet it has something to do with there being a space in the filename seeing as the filename in the headers is PSP_Tubes_PSP_Tubes_Lisa_Cree_The Gift_6932.zip and the file wants to be save as PSP_Tubes_PSP_Tubes_Lisa_Cree_The.

Upvotes: 2

The problem could be that some files have spaces, in that case with your current code only the first part is used so loosing the extension part, to prevent such error you have to enclose the filename in double quotes, like so:

header('Content-Disposition: attachment; filename="'.$originalfilename.'"');

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799470

Add a dummy GET parameter that looks like a filename.

...&fname=/foo.zip

Upvotes: 0

Related Questions