The point is this. There is a code

header('Content-Disposition: attachment; filename="file_name.zip"'); 

This header does not support the full address of the file location. Can I somehow fix this, so that, say, such an address can be inserted

 http://hostname.net/folder/file_name.zip 
  • filename="file_name.zip" simply specifies how to default name the uploaded file. And to start the download, the contents of the file must somehow be passed to the user. - ling
  • thank. I did not know))) - Alexof

3 answers 3

Um? Do you want the user to download a file from another resource?

If so, do:

 header('Location: http://hostname.net/folder/file_name.zip'); 

UPD

mmmm no.) I want it from mine (the same as the page), but the script is in one folder and the file in another. The address is formed dynamically.

then:

 header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="file_name.zip"'); readfile('/local/path/to/file'); 
  • mmmm no.) I want it from mine (the same as the page), but the script is in one folder and the file in another. The address is formed dynamically. - Alexof
  • updated the answer - Alex Kapustin
  • thank!!! works! - Alexof

After all the headlines:

 echo file_get_contents("folder/file_name.zip"); 

    Hm

     header('Content-Type: image/jpeg'); // изображение в формате JPG header('Content-Type: application/zip'); // ZIP-файл header('Content-Type: application/pdf'); // PDF-файл 

    Further, as “Yoharny Babai” said, the current is not echo, but rather print_r(file_get_contents("folder/file_name.zip")); echo-th may not be completely transferred to the file)

    • one
      For universality))) header ('Content-Type: application / octet-stream'); - Fucking Babai
    • odd fails. when switching to a script, it gives a script file for downloading - Alexof