Php file upload and download

Source: Internet
Author: User
You can use the move_uploaded_file () function to upload and download php files.
However, this document does not introduce how to download files. I cannot find the move_downloaded_file () function.
I want to download move_uploaded_file () and upload it from the directory you uploaded to your specified download directory. this is strange.
Which eldest brother shared the php file download method.


Reply to discussion (solution)

You can upload move_uploaded_file because the uploaded file is already on the server.
Download is naturally not move_uploaded_file, because the file is on the server, you download it to the client...
The easiest way to download
If you do not want to expose the file address.
Available:
Header ("xxxxxxxxxx ");
Readfile ("file ");
Upload the file content to the browser for download.

There are a lot of downloaded materials, such as google and baidu ..

You can upload move_uploaded_file because the uploaded file is already on the server.
Download is naturally not move_uploaded_file, because the file is on the server, you download it to the client...
The easiest way to download
If you do not want to expose the file address.
Available:
Header ("xxxxxxxxxx ");
Readfile ("file ");
Upload the file content to the browser for download.

There are a lot of downloaded materials, such as google and baidu ..



Header ("xxxxxxxxxx"); what is the role of this sentence?
If only readfile ("file") is used, the download box is not displayed, and only the content in the file is displayed.

  


Download.

  


Download.




When downloading an object, why do you need to determine the browser (preg_match ("/Firefox/", $ user_agent )?
Header ('content-disposition: attachment; filename = "'. $ encode_filename .'"');
What is the use of header ('XXX')? when I remove readfile ($ file), the file content is displayed in the browser, and no download box is displayed.


  


Download.




When downloading an object, why do you need to determine the browser (preg_match ("/Firefox/", $ user_agent )?
Header ('content-disposition: attachment; filename = "'. $ encode_filename .'"');
What is the use of header ('XXX')? when I remove readfile ($ file), the file content is displayed in the browser, and no download box is displayed.


Sets the file header. when the browser receives the header, the file download dialog box is activated.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.