【问题标题】:Uploadify completes but doesn't uploadUploadify 完成但不上传
【发布时间】:2012-07-08 08:07:44
【问题描述】:

我正在尝试在我的网站上使用 Uploadify 并使用以下 uploadify.php 进行设置:

<?php
// Define a destination
//$targetFolder = '/uploads'; // Relative to the root

if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'];
$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.';
}
}
?>

它没有上传,所以我注释掉了 $targetFolder 并更改了 $targetPath 以便它只是文档根目录。当我尝试使用 Uploadify 上传 file.txt 时,这导致 $targetFile 成为 /home/user/public_html/example.com/file.txt。该文件夹设置为 755。我不知道问题可能是什么。否则,我正在使用 Uploadify 的香草安装,一切似乎都工作正常,除了文件实际上从未到达应有的位置。

【问题讨论】:

  • move_uploaded_file 如果失败应该返回警告
  • $foo=move_uploaded_file ... var_dump($foo);

标签: php uploadify


【解决方案1】:

文件夹权限没有保持设置为 755 是一个问题。我退出并重新登录 cPanel,现在一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-20
    • 1970-01-01
    • 2011-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-01
    • 1970-01-01
    相关资源
    最近更新 更多