2012-07-08 51 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,現在一切正常。

相關問題