uploadify显示上传成功,文件夹中没有文件

时间:2012-12-11 17:00:18

标签: php jquery file-upload

我已经阅读了有关uploadify的所有帖子,说明上传成功但没有上传文件,没有一个解决方案有效。有人可以看看代码,看看我是否遗漏了一些东西。我还运行了一个phpinfo(),它说我的文件上传已打开。我正在使用uploadify 3.1。

<!DOCTYPE html>
<html>
<head>
    <title>My Uploadify Implementation</title>
    <link rel="stylesheet" type="text/css" href="uploadify.css">
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="jquery.uploadify-3.1.min.js"></script>
    <script type="text/javascript">
    $(function() {
        $('#file_upload').uploadify({
            'swf'      : 'uploadify.swf',
            'uploader' : 'uploadify.php'
            // Your options here
        });
    });
    </script>
</head>
<body>
<input type="file" name="file_upload" id="file_upload" />
</body>
</html>
// Define a destination
$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.';
  }
}
?>

0 个答案:

没有答案