View Full Version : php question
10-13-2004, 09:27 AM
Assuming my server is configured to treat http exe requests as php scripts how can I choose a different file to serve based on the results of some test? For example.. suppose someone downloads
I'd like to have some php code run at that point which basically does
give downloader file x.exe
give downloader file x2.exe
10-13-2004, 10:30 AM
I believe you'll have to put the "x.exe" and "x2.exe" files in a different directory than the script, because the script and first file are both named "x.exe".
This may work, or at least may be a place to start. It's put together from a download script I use on several sites:
$filename = "x.exe";
$filename = "x2.exe";
Header("Content-Disposition: attachment; filename=".$filename);
10-13-2004, 10:36 AM
Or even better
@Tom : I avoid manually using download headers whenever I can, I've read many posts in this forums reporting misc problems with that. Did you have any problem using these?
I wouldn't treat "*.exe" as php files... that's just odd. Use rewrite rules instead.
RewriteRule downloads/(.*) jarbounce.php?file=$1 [NE]
It's this for the user:
And this internally:
This way you can run scripts and whatsoever... and even the crappiest browsers out there won't have a chance to screw anything up (because there is no difference on their side ;)).
10-13-2004, 10:50 AM
I've never had trouble with these download headers, even when building sites with old browser requirements. I've heard of problems also, but I've never seen them or had anyone report them not working on sites I've built. I thought the server in this scenario would treat the exe files as php scripts if the download headers weren't used, but I have never worked with a server configured to treat exe files as php scripts, so maybe it will download fine without the download headers.
oNyx's solution, though, looks like a simpler way to achieve the desired result.
Oh I forgot to mention xampp.
It's a complete (free) package. Apache, php, mysql and perl. After running the installer you have a nicely configurated running webserver, which you can use for "toying" around (did that the whole day long... duh) ;)
Without a local server testing such stuff would be quite painfull. [On a second thought... most likely you already have one, but I still think it's good to post that for the guys who don't have one]
10-13-2004, 01:58 PM
Arse :) I spent a while the other week setting up Apache and friends to test my php scripts.. thanks for the link...
10-13-2004, 02:16 PM
Awesome! I formatted and reloaded my system over the weekend, and just last night I downloaded the latest Apache, MySQL and PHP to get a test server running. Luckily I haven't installed and configured anything yet so I can use XAMPP instead. :) Thanks for the link!
10-13-2004, 11:06 PM
svero, you may want to use this in combination with oNyx's post about RewriteRule (don't treat exes as php files!), as this will (hopefully) work with apps like GetRight to allow them to break files up into parts for simultaneous downloading: http://forums.indiegamer.com/showpost.php?p=8056&postcount=20
Powered by vBulletin™ Version 4.1.3 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.