Reputation: 545
I have my file generate_xls.php
and is creating a file.xls
and want to save it in a folder. What is to do now is download the file. I have the following:
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment;Filename=ocorrencias.xls");
echo "write in file xls";
The file is being created as well, but what I want is to save the file in a folder in my server and not download it. Is there any change in header
to do that?
Upvotes: 0
Views: 5900
Reputation: 9520
HTTP headers are part of the HTTP requests and responses that are sent when communicating across a network. They hold information about the client, the server, the information being sent, and more.
If a script creates a file and sends it to a client, the script should create the appropriate headers to notify the client what the file type is (Content-type: application/vnd.ms-excel
), whether to download it directly (Content-Disposition: attachment
) or view it in a web browser, and so on.
If the script creates a file and saves it to the server (e.g. using file_put_contents($file_name, $data)
), no headers need to be set as the file is not being sent across the network. If someone subsequently wants to download the file, e.g. using an FTP client or using another script, that script or FTP program on the server will set the appropriate headers when the transfer occurs.
Upvotes: 1