Create xls file and store in a folder

Asked

Viewed 668 times

3

I have my file gerar_xls.php and is creating a file .xls and I want to keep it in a folder. What you are doing now is downloading the file. 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 well created, but what I want is to store the file in a folder inside the server and not download it. Is there any change in the header do that?

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), is to download directly (Conteúdo -Disposition: attachment) or 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. If someone wants later to download the file, for example using an FTP client or using another script, this script or FTP program on the server will set the appropriate headers when the transfer takes place.

Source: https://stackoverflow.com/questions/26021162/create-xls-file-and-save-to-a-folder

Browser other questions tagged

You are not signed in. Login or sign up in order to post.