首页 > 解决方案 > 在目录中安装文件的 PHP 脚本

问题描述

我需要一个 PHP 脚本,将文件安装example.php到特定目录中。任何帮助,将不胜感激。

我已经有一个用于制作目录的脚本。这里是:

if (!file_exists("img/{$userName}")) {
    mkdir("img/{$userName}", 0777, true);
}

$userName 变量只是一个会话变量:

$userName = $_SESSION["username"];

标签: php

解决方案


用 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 )


推荐阅读