表示我的服务器 www.abc.com
在我的服务器中有子文件夹图像其中有一个 excel 文件,即 a.xls;我想将此文件下载到我的本地计算机我需要相同的 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);
?>
将上面的代码保存为下载.php并执行下载