php - 在目录中安装文件的 PHP 脚本
问题描述
我需要一个 PHP 脚本,将文件安装example.php
到特定目录中。任何帮助,将不胜感激。
我已经有一个用于制作目录的脚本。这里是:
if (!file_exists("img/{$userName}")) {
mkdir("img/{$userName}", 0777, true);
}
$userName 变量只是一个会话变量:
$userName = $_SESSION["username"];
解决方案
用 PHP 试试这个例子:
$URL = ...; // Like "http:// ...."
$FileToSave = ...; // Like "/home/.." or "C:/..."
$Content = file_get_contents($URL);
file_put_contents($FileToSave, $Content);
@NawaMan 的归属于 ( https://stackoverflow.com/a/3532808/14945696 )
推荐阅读
- c# - 输入字符串的格式不正确?
- java - 如何在java中将对象响应映射到另一个ObjectDto
- c# - 使用 VB.NET 表单从 SQL Server 到 Excel 的日期数据检索
- react-native - 如何在本机反应中重置嵌套导航器中的导航堆栈状态
- r - 如何在R编程中将数据动态输入矩阵
- heroku - 如何修复 Multer-Gridfs-Storage 错误“创建存储引擎时出错。必须提供至少一个 url 或 db 选项”?
- python - 使用 Spyder 4.1.4 和 python 3.8 进行正确的验证循环
- python - Python:使用 xlrd 库从 excel 电子表格中读取数据给了我不正确的行数
- json - 使用 Scala 在 Spark 中将 JSON 对象更改为 JSON 列表
- javascript - 按下 esc 键时有没有办法滚动到顶部?