Let users download directory files?
I have a script that lists all files in a directory. It works fine, except, I want users to be able to download the files. The problem is that if a user downloads a php file, for example, it saves as an html file. How do I change this? I don't want the user to have to change the file extension manually.
Let users download directory files?internet security
Kaspersky Internet Security 2011 keeps your PC free from malicious code, adware, spyware, hacker attacks, spam and network fraud.
On the code where you allow the user to download the file, you need to add header information of what type of file is downloading. By default it will treat it as plain text / html unless specified.
example for a pdf file
<?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');
?>
Let users download directory files?network security
You have not enabled email on your profile so I couldnt reply to your question . You dont have to code for individual files. you got to put a loop that will iterate through all the files and list them using the above code. Hope that helps Report It |||Alternatively, you can give read access to the files in the directory and enable that folder to be accessable on your website. I wouldnt recommend that though..Email me using the email link on my profile if you have questions on this as I wont be checking this question for the comments. Report It
More Related Questions and Answers ...
The information post by website user , we not guarantee correctness.
eScan Internet Security Suite (3 user, 1 year) with eConceal Firewall FREE