简体   繁体   中英

Download files from HTTPS url PHP

I am writing PHP Script for downloading files from wetransfer ( Wetransfer )

i have got php script php script to download from wetransfer

The above is great but it has some issues that --

  1. we need to provide "output" file ( like "filename.zip") , HOW we come to know that which type of file we are downloading.

  2. will the script also work for file having GB of size.?

one more thing that wetransfer provides short link , i am able to convert that short link into long url , this long url is used in the above code.

any help.

  1. After you download file you can check MIME type with mime_content_type()

  2. It depends on server settings. Also remember that php has so timeout. Maybe it would be better if you use some kind of queue to do it asynchronously.

  3. It would be better to use readfile() instead of fread() , readfile() won't cause memory problems.
  4. It is important to turn off output buffering when downloading large files.

Note: readfile() will not present any memory issues, even when sending large files, on its own. If you encounter an out of memory error ensure that output buffering is off with ob_get_level().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM