How to setup the apache server to allow http downloading?
I installed apache, mysql, php on my windows vista laptop, and want to test http downloading. This means when selecting a file (for example, contact.php) from a page, and then click download, it will be downloaded to my desktop.
Do we need to install any other softwares to do that?
if you have php installed and working fine, then contact.php will be processed and displayed on your browser, you will not be able to download it. The easiest way to make php files download is to unload the php module from your apache.
I'm now developing a file manager for my website, and when selecting the php, html files and click the download button, I want these files to be downloaded. Each web hosting provider offers a file manager with this kind of function, I want my own.
typically a 'file manager' would let you edit a file by loading
the contents into a 'textarea' box in a form. this is relatively
trivial. you could then save this to local disk perhaps.
there's lots of free php control panels, some may have
'file managers' so you could get them and read the source code.
examples are: syscp, webcp, baifox, ISPConfig, dtc, ispcp
and probably some more too. use google to find them.
I would suggest using a single download script (e.g. download.php) and passing the path to download using either a query string parameter or extra path info. Then use readfile() to return the data to the user.
You will need to make sure you have proper access control checking and that you set the HTTP headers appropriately. There are several headers you need to pay attention to, including Content-Type, Content-Disposition, and Last-Modified.