You can't. The SitePoint chap was talking about using PHP, which is probably what I'd have to suggest here too.
Printable View
You can't. The SitePoint chap was talking about using PHP, which is probably what I'd have to suggest here too.
Ok...well maybe you can give me a quick lecture if you don't mind. It will be greatly appreciated.
Let's say I have a .zip file in a protected directory. Once a user has successfully logged in with their email and password in order to download their software, how do I output the '.zip' file to them?
Is it possible to give me exact code for this? I've been searching around the web, but I can't seem to get something that works. Also...I don't have experience with the HTTP headers of outputting a file using PHP readfile()
Thanks alot for your help.
It's simple:Code:$data = file_get_contents('file.zip');
header('Content-Type: application/x-zip');
header('Content-Length: ' . strlen($data));
header('Content-Disposition: attachment; filename=file.zip');
die($data);
Great. I appreciate this. And then I just echo $data ? Is that right?Quote:
Originally Posted by Twey
I've tried something different now. You code also basically gave me the same problem. Here is my code :
What should I do? Basically I just need a dialog asking them if they want to download. I'm sorry for all these questions, but I really have no idea how to do this. All help is appreciated.PHP Code:<?php
$filename = "download/setup4u.zip";
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: application/x-zip");
// change, added quotes to allow spaces in filenames, by Rajkumar Singh
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile("$filename");
exit();
?>
Here is the URL :
http://www.pcsnoop.tv/testdownload.php
No, I've already done that :)Quote:
Great. I appreciate this. And then I just echo $data ? Is that right?
Either code should give the standard "do you want to save or open this file" dialog box on most configurations.
It should be noted that double quotes take significantly longer to parse than single quotes.
Please look at my previous post with the code and the URL.
It seems to be working perfectly in FireFox, but in IE it just throws out alot of encrypted code. Damn...I'm getting really annoyed by IE...
I'll be SO happy if I can get this working.
I've been struggling with this for a very long time really.
I know it's simple and all, but yeah...
Urgh, IE doing its content-type-guessing thing again?
Well, your server is sending the header:It should be application/x-zip.Code:Content-Type: application/zip
I've tried x-zip but it also doesn't work.
What is it with IE? I have these problems everyday. I had a JS problem, which I sorted out today thanks to you on another thread. This was also ONLY in IE.
So what will I do? This dialog works perfectly fine in FireFox, but probably about 75% in the US use IE, and I have to cater for them.