【问题标题】:loading images from html /wordpress using php使用 php 从 html /wordpress 加载图像
【发布时间】:2016-09-29 17:24:27
【问题描述】:

我正在尝试使用 W3Schools 的代码将图像文件加载到我的 wordpress 空间。

但是,move_uploaded_file 失败。

我在网站上添加了包含file_uploads = Onphp.ini

我已将目标目录的文件权限设置为 777。

我该如何解决这个问题?

【问题讨论】:

  • 当您说您使用包含file_uploads = On 的php.ini 对站点进行攻击 时,您是什么意思?另外,您用来移动文件的代码是什么,围绕move_uploaded_file 函数?请发布您的代码!

标签: php html wordpress image


【解决方案1】:

这是有效的代码

if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";

} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
    echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
    echo "Sorry, there was an error uploading your file.";
}

}

我把 php.ini 放在特定的插件文件夹和 wordpress 基础文件夹中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-05
    • 2021-06-24
    • 2015-12-21
    相关资源
    最近更新 更多