Home php download file from server

download file from server

Author

Date

Category

Furize to organize the file download. What I just did not reprint, but the browser persistently tries to open the file, and not download.


Answer 1, Authority 100%

$ file = '/path/to/file.jpg';
Header ('Content-Type: Image / JPEG');
Header ('Content-Disposition: attachment; filename = "file.jpg"');
readfile ($ File);

File name and Content-Type specify for your specific file.


Answer 2, Authority 67%

$ file_name = $ myrow ['file'];
 Header ("Content-Length:" .FileSize ($ file_name));
 Header ("Content-Disposition: attachment; filename =". $ file_name);
 Header ("Content-Type: Application / X-Force-Download; Name = \" ". $ file_name." \ "");
 dfile ($ file_name);

shakes files of any extension

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions