Create xls file and save to a folder

3

I have my file gerar_xls.php and you are creating a file .xls and I want to save it in a folder. What you are doing now is the file download. I have the following:

header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment;Filename=ocorrencias.xls");

echo "escrever no ficheiro xls";

The file is being created, but I want to save the file to a folder inside the server and not download it. Is there any change in header that does this?

    
asked by anonymous 24.09.2014 / 17:20

1 answer

2

HTTP headers are part of the HTTP requests and responses that are sent when communicating over a network. They hold information about the client, the server, the information to be sent and more.

If a script creates a file and sends it to a client, the script must create the appropriate headers to notify the client that the file type is (Content-type: application / vnd.ms-excel) , either to directly download (Conteúdo -Disposition: attachment) or to view it in a web browser, and so on.

If the script creates a file and saves it to the server (for example, using file_put_contents ($ nome_do_arquivo, $ dados)) , no header needs to be set as the file is not being sent over the network. eg by using an FTP client or by using another script, this script or FTP program on the server will set the appropriate headers when the transfer occurs.

Source: link

    
24.09.2014 / 18:40