PHP自动下载文件 [英] PHP automatically download file
本文介绍了PHP自动下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以让PHP从远程服务器下载文件并将其保存在本地文件夹中?
Is it possible to have PHP download a file from a remote server and save it in a local folder?
EDIT
我不知道这是一个重复的问题。发布之前,我进行了搜索,但是正在搜索 php自动下载文件,并获得了有关如何强制浏览器下载文件而不是打开文件的结果。
I didn't know this was a duplicate question. Before posting I did search, but was searching for "php automatically download file" and was getting results on how to force a browser to download a file instead of opening it.
推荐答案
<?php
// set url "http://
curl_setopt($ch, CURLOPT_URL, "<your url>");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
file_put_contents($output,"<file>";
?>
这篇关于PHP自动下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文