| | |
PHP in a html page?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Try the following:
[PHP]<?php
$file = 'http://www.martinkorner.host.sk/Swim.exe'; //Windows
$file = '/mnt/storage/users/m/a/r/martinkorner/Swim.exe'; //or Linux
$new_filename = '"Swim To The Sea.exe"';
{
header("HTTP/1.1 200 OK");
header("Status: 200 OK");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$new_filename);
readfile($file);
exit();
}
?> [/PHP]
$file = 'http://www.martinkorner.host.sk/Swim.exe'; //Windows
You understand that the line below completely overwrites the line above right?
$file = '/mnt/storage/users/m/a/r/martinkorner/Swim.exe'; //or Linux
[PHP]<?php
$file = 'http://www.martinkorner.host.sk/Swim.exe'; //Windows
$file = '/mnt/storage/users/m/a/r/martinkorner/Swim.exe'; //or Linux
$new_filename = '"Swim To The Sea.exe"';
{
header("HTTP/1.1 200 OK");
header("Status: 200 OK");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$new_filename);
readfile($file);
exit();
}
?> [/PHP]
$file = 'http://www.martinkorner.host.sk/Swim.exe'; //Windows
You understand that the line below completely overwrites the line above right?
$file = '/mnt/storage/users/m/a/r/martinkorner/Swim.exe'; //or Linux
The reference was to the operating system on the server, not the client-side operating system. Use the linux one. It is the one that has been being used anyway.
•
•
•
•
Originally Posted by martinkorner
So If I use the windows one, will linux users still be able to access the download?
Martin
You would have to take that program and recompile it for a linux users (this is way more technical, and not within the scope of this forum). But yes the linux users will be able to download it.
•
•
•
•
Originally Posted by paradox814
yes they will, but realisticly speaking it will do them no good, exe files are generally compiled for windows, not linux users (unless they use wine).
You would have to take that program and recompile it for a linux users (this is way more technical, and not within the scope of this forum). But yes the linux users will be able to download it.
Martin
I removed the space before the "<?php" tag and now it works properly in both browsers! (Thanks DanceInstructor for the pm).
At the moment that just downloads over the previous page, how would I get it to link to a html page, so for example, the user clicks a link which takes them to a page saying: "You're download should have started, if not please click here." and the download dialogue box appears.
Thanks
Martin
At the moment that just downloads over the previous page, how would I get it to link to a html page, so for example, the user clicks a link which takes them to a page saying: "You're download should have started, if not please click here." and the download dialogue box appears.
Thanks
Martin
![]() |
Similar Threads
- Can I use a template html page within another html page (Site Layout and Usability)
- php contact page (PHP)
- How To Hyperlink Normal HTML page with ASP.NET Page? (ASP.NET)
- How to Embed CheckList Box on HTML Page using Java Script (HTML and CSS)
- Calling function to add HTML to the page (ASP.NET)
- Use php to load a page in a page? (PHP)
Other Threads in the PHP Forum
- Previous Thread: tomorrow date??? .
- Next Thread: Looking for an Asset Tracking system
| Thread Tools | Search this Thread |
ajax apache api array arrays beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external file files folder form forms forum function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert integration ip java javascript joomla limit link login loop mail malfunction menu method mlm multiple mysql neutrality oop paypal pdf php phpmysql play problem query question radio random recursion regex remote root script search select server sessions sms soap source space sql syntax system table tutorial update upload url validator variable video web xml youtube





