ev5unleash Posted July 18, 2008 Share Posted July 18, 2008 I was wondering how to do a php file request. I already know how to do a page request but I want to know how to make it so I when someone requests "downloads?id=smartboardsolution(.exe)" they get the file download "smartboardsolution.exe". Link to comment https://forums.phpfreaks.com/topic/115445-php-based-file-request/ Share on other sites More sharing options...
JasonLewis Posted July 18, 2008 Share Posted July 18, 2008 I think you can use header() to do that. Copied from php.net: <?php // We'll be outputting a PDF header('Content-type: application/pdf'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // The PDF source is in original.pdf readfile('original.pdf'); ?> Link to comment https://forums.phpfreaks.com/topic/115445-php-based-file-request/#findComment-593480 Share on other sites More sharing options...
ev5unleash Posted July 18, 2008 Author Share Posted July 18, 2008 What if it's an .exe file? Link to comment https://forums.phpfreaks.com/topic/115445-php-based-file-request/#findComment-593514 Share on other sites More sharing options...
JasonLewis Posted July 18, 2008 Share Posted July 18, 2008 Try this: <?php header('Content-type: application/exe'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="linktofile.exe"'); // The PDF source is in original.pdf readfile('linktofile.exe'); ?> I am not to sure though, as I've never had to do it. Link to comment https://forums.phpfreaks.com/topic/115445-php-based-file-request/#findComment-593524 Share on other sites More sharing options...
ev5unleash Posted July 18, 2008 Author Share Posted July 18, 2008 Alright, I'll try it when I get the chance. Link to comment https://forums.phpfreaks.com/topic/115445-php-based-file-request/#findComment-593740 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.