简体   繁体   中英

required php code to download a file from sub folder of a server

say my server is www.abc.com

In my server there is sub folder images in which one excel file is there ieaxls; I would like to download this file to my local computer I need php code for the same

This is not PHP but I want to share my solution. How about "wget" on Linux or cygwin on Windows.
1. Create a that list all files needed to dowload "list.txt" (One file one line)
2. Create a shell script file "download.sh"

while read file; do
    wget $file
done < /path/to/file/list.txt

3. On linux, make "download.sh" available to executed.

chmod +x /path/to/file/download.sh

4. Execute file

./path/to/file/download.sh

Try file_get_contents

<?php
    header('Content-type: application/vnd.ms-excel');
    header('Content-Disposition: attachment; filename="excelsheet.xls"');
    $file_path = "www.abc.com/image/excelsheet.xls";
    echo file_get_contents($file_path);
?>

Save the above code as download.php and execute to download

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