2012-07-08 48 views
2

我试图用Uploadify我的网站上,并将它设置有以下uploadify.php:Uploadify完成,但不会上传

<?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的一个vanilla安装,并且一切看起来都很好,除了该文件从未真正进入它应该在的位置。

+0

如果失败,move_uploaded_file应该会返回警告 – 2012-07-08 20:28:06

+0

我在错误日志中看不到任何警告。 – user1461465 2012-07-08 20:34:18

+0

$ foo = move_uploaded_file ... var_dump($ foo); – 2012-07-08 20:36:39

回答

0

这是一个问题,文件夹权限不停留设置为755.我退出并重新进入cPanel,现在一切正常。