php - 使用 PHP 从 HTTP 下载文件
问题描述
我正在尝试使用 PHP 从此链接http://192.168.1.9:8080/savegame4下载文件,但它给了我一个错误提示
file_get_contents( http://192.168.1.9:8080/savegame4 ):打开流失败:HTTP 请求失败!HTTP/1.1 404
该链接是下载的直接链接,因为我无法获得其他链接
这是我下面的代码。
$url = 'http://192.168.1.9:8080/savegame4';
$file_name = basename($url);
if(file_put_contents( $file_name,file_get_contents($url))) {
echo "File downloaded successfully";
}
else {
echo "File downloading failed.";
}
解决方案
推荐阅读
- mongodb - 无法使用指南针连接到 mongodb,但可以通过 mongo shell?
- c++ - 无法访问 CMake UPW 项目中的文件系统
- ios - Xcode12:在 Swift 本地包中的 xcassets 文件中定义的颜色在通过 IB Storyboard 应用时不显示深色外观
- python - 两个 Numpy 数组之间的点积和度数
- node.js - 从 JSON 到行的 NodeJs
- python - 如何在 Python Tkinter 中绑定 ComboBox 的 ListBox
- angular - 为什么不只使用两种方式的数据绑定?
- pandas - 当列包含某些文本时,将所有列值连接到 1 列
- c# - 我可以使用 C# 中另一个方法内部的 foreach 循环中的方法链接来调用方法吗?
- elasticsearch - 在 Elasticsearch 中索引字符串的最后一个单词