1

我最近在我的网站http://tradersprinting.com/contact/send-file-2/上安装了 uploadifive ,每次尝试上传文件时都会遇到 404 错误。

该站点由 WordPress 内容管理系统提供支持,该站点托管在 1&1 上。uploadify 文件存储在目录中:“http://tradersprinting.com/wp-content/themes/traders/uploadify”。WordPress 函数“bloginfo('template_directory')”返回“http://tradersprinting.com/wp-content/themes/traders/”。目前一切都处于“出厂设置”,没有任何调整,保存我附在下面的代码片段:

页面上的代码http://tradersprinting.com/contact/send-file-2/

  <?php
    chmod("wp-content/themes/traders/uploads/",0777);
    chmod("wp-content/themes/traders/uploadify/uploads/",0777);
  ?>
  <script src="<?php bloginfo('template_directory'); ?>/uploadify/jquery.min.js" type="text/javascript">
  </script>
  <script src="<?php bloginfo('template_directory'); ?>/uploadify/jquery.uploadifive.min.js" type="text/javascript">
  </script>
  <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/uploadify/uploadifive.css">
  <style type="text/css">
    body {
      font: 13px Arial, Helvetica, Sans-serif;
    }
    .uploadifive-button {
      float: left;
      margin-right: 10px;
    }
    #queue {
      border: 1px solid #E5E5E5;
      height: 177px;
      overflow: auto;
      margin-bottom: 10px;
      padding: 0 3px 3px;
      width: 300px;
    }
  </style>
  <form>
    <div id="queue">
    </div>
    <input id="file_upload" name="file_upload" type="file" multiple="true">
    <a style="position: relative; top: 8px;" href="javascript:$('#file_upload').uploadifive('upload')">Upload Files</a>
  </form>
  <script type="text/javascript">
    <?php $timestamp = time();?>
      $(function() {
      $('#file_upload').uploadifive({
        'auto'             : false,
        'checkScript'      : 'check-exists.php',
        'formData'         : {
          'timestamp' : '<?php echo $timestamp;?>',
          'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
        },
        'queueID'          : 'queue',
        'uploadScript'     : 'uploadifive.php',
        'onUploadComplete' : function(file, data) { console.log(data); }
      });
    });
  </script>

我的uploadifive.php 副本

<?php
/*
UploadiFive
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
*/

// Set the uplaod directory
$uploadDir = '/uploads/';

// Set the allowed file extensions
$fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // Allowed file extensions

$verifyToken = md5('unique_salt' . $_POST['timestamp']);

if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
    $tempFile   = $_FILES['Filedata']['tmp_name'];
    //  Commenting out this line as a potential bugfix for 404 error
    //$uploadDir  = $_SERVER['DOCUMENT_ROOT'] . $uploadDir;
    $uploadDir = "/wp-content/themes/traders/uploadify/uploads";
    $targetFile = $uploadDir . $_FILES['Filedata']['name'];

    // Validate the filetype
    $fileParts = pathinfo($_FILES['Filedata']['name']);
    if (in_array(strtolower($fileParts['extension']), $fileTypes)) {

        // Save the file
        move_uploaded_file($tempFile, $targetFile);
        echo 1;

    } else {

        // The file type wasn't allowed
        echo 'Invalid file type.';

    }
}
?>

我在从根目录开始的目录树的每个分支中创建了一个“上传”目录,并且在到示例 uploadify 目录的每一步都包括一个目录,但它们都没有接收文件。

我喜欢这个程序,我认为设计师做得很出色,但我真的很想让产品工作,尤其是在投资之后!请帮忙!

4

1 回答 1

0

Uploadify uses a Flash SWF based uploader. In many cases Apache web server's mod_security module prevents data uploaded by any SWF. So I'd say check server's mod_security log (not Apache error log) if it is blocking your script.

于 2013-01-05T13:27:02.057 回答