【问题标题】:Uploadify errors. Not uploading images.上传错误。不上传图片。
【发布时间】:2011-11-06 10:03:35
【问题描述】:

我正在尝试让 uploadify 上传,但它返回了一些错误:

以下是错误:

<b>Warning</b>:  move_uploaded_file(/home/mydomain/public_html/uploadslogo.png) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: Permission denied in <b>/home/mydomain/public_html/uploadify/uploadify.php</b> on line <b>37</b><br />
<br />


<b>Warning</b>:  move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/tmp/phpvoUwxK' to '/home/mydomain/public_html/uploadslogo.png' in <b>/home/domain/public_html/uploadify/uploadify.php</b> on line <b>37</b><br />
1true

这里是uploadify.php代码:

<?php

$targetFolder = '/uploads'; // Relative to the root

if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
    $targetFile = rtrim($targetPath,'/') . $_FILES['Filedata']['name'];

    // Validate the file type
    $fileTypes = array('jpg','jpeg','gif','png'); // File extensions
    $fileParts = pathinfo($_FILES['Filedata']['name']);

    if (in_array($fileParts['extension'],$fileTypes)) {
        move_uploaded_file($tempFile,$targetFile);
        echo '1';
    } else {
        echo 'Invalid file type.';
    }
}
?>

【问题讨论】:

    标签: javascript jquery uploadify


    【解决方案1】:

    您错过了uploads 目录后面的斜杠。试试:

    $targetFolder = '/uploads/'; // Relative to the root
    

    你也想改变:

    $targetFile = rtrim($targetPath,'/') . $_FILES['Filedata']['name']; 
    

    收件人:

    $targetFile = $targetPath . $_FILES['Filedata']['name'];
    

    【讨论】:

    • 已更改但仍然出现相同的错误:警告: move_uploaded_file(/home/mydomain/public_html/uploadslogo.png) [function.move-uploaded-file]:无法打开流:/home/mydomain/public_html/uploadify/uploadify.php37 行的权限被拒绝
    • 后面的斜杠被以下行删除: $targetFile = rtrim($targetPath,'/') 。 $_FILES['文件数据']['名称'];将其更改为: $targetFile = $targetPath 。 $_FILES['文件数据']['名称'];
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-02
    • 1970-01-01
    • 2016-03-08
    • 2016-01-02
    • 2018-06-22
    相关资源
    最近更新 更多