繁体   English   中英

从服务器的子文件夹下载文件所需的php代码

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

说我的服务器是www.abc.com

在我的服务器中,有子文件夹图像,其中有一个excel文件。 我想将此文件下载到我的本地计算机,同样需要php代码

这不是PHP,但我想分享我的解决方案。 如何在Linux上使用“ wget”或在Windows上使用cygwin。
1.创建一个列出下载“ list.txt”所需的所有文件的文件(一个文件一行)
2.创建一个shell脚本文件“ download.sh”

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

3.在linux上,使“ download.sh”可用于执行。

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

4.执行文件

./path/to/file/download.sh

试试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);
?>

将以上代码另存为download.php并执行下载

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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