2

我正在尝试在我的网站上使用 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 的香草安装,一切似乎都工作正常,除了文件实际上从未到达应有的位置。

4

1 回答 1

0

这是文件夹权限未设置为 755 的问题。我退出并重新登录 cPanel,现在一切正常。

于 2012-07-08T20:40:39.367 回答