Sometime we ask visitors to download files from a web site. In this site also you can download many codes in zip format. We can ask the visitor to download the file and point one simple link to the zip file. On clicking the link the visitorís browser will show a window to save the zip file in client machine. But the problem comes when we donít have a file or a fixed URL to create a link. Say if a member is downloading his / her address book in CSV format then the records of this file is created on the fly. The records of the member is taken out from a table and formatted as per CSV file format and then the visitor / member gets a prompt to save the CSV file in the client machine. How to do this ?
Here by using the header option we will tell the browser that the file format is different then what it opens. We can set a default file name for the file also. Here is the code to do this. Note that in the second line we are specifying the default file name. In the third and fourth line we are storing the data and sending it to the client machine through the file download.
header("Content-Disposition: attachment; filename=\"my-data.csv\"");
$data="col1, col start and end col2,col3, \n";
$data .= "seond linedata here from site to download col1";
please php script to display doc. file not image e g microsft word
The code below works on my localhost to download a file. However, on top of my downloaded file there are 160 lines of HTML tags. How can I eliminate these tags and just get the plain file?
I appreciate your advice.
$fd = basename($csv);
header("Content-Disposition: attachment; filename="".$fd.""");
how to create download from server exact code.
and how to create file read, file write, file append exact code.