Uploadify 3.2.1表示文件已上传但无法查看

时间:2013-08-13 20:01:24

标签: uploadify

我搜索了很多帖子来解决我的问题,尝试过很多东西但它对我没用。问题是我尝试使用Uploadify插件(v3.2.1)提供的演示页面上传文件,并且说下载已完成,但我无法在服务器上看到该文件。

首先,假设我已在 public_html 文件夹中修改了 php.ini ,以设置 upload_tmp_dir 的路径session.savepath 即可。我已将两者都设置为: / home / ensembl / public_html / accp / uploadTemp

然后,再次在public_html文件夹中,我创建了 .htaccess 文件并将此行写入其中: suPHP_ConfigPath / home / ensembl / public_html / 以申请对所有文件和子文件夹的更改。

所有文件夹都拥有0755权限,所有文件都有0644。

有人看到了什么问题吗?

现在有了我现在的代码:

的index.php

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>UploadiFive Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="jquery.uploadify.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="uploadify.css">
<style type="text/css">
body {
    font: 13px Arial, Helvetica, Sans-serif;
}
</style>
</head>

<body>
    <h1>Uploadify Demo <?php
    //The following line is just to show the paths
    echo $_SERVER['DOCUMENT_ROOT'].'/downloadsUploadify/'.'<br/>'.sys_get_temp_dir().' | '.ini_get('upload_tmp_dir');?></h1>
    <form>
        <div id="queue"></div>
        <input id="file_upload" name="file_upload" type="file" multiple="true">
    </form>

    <script type="text/javascript">
    $(function() {
        $('#file_upload').uploadify({
            'swf'           : 'uploadify.swf',
            'uploader'      : 'uploadify.php',
            'fileSizeLimit' : '20MB',
            'fileTypeExts' : '*.jpg; *.jpeg; *.gif; *.png; *.mp3; *.pdf; *.txt',
            'removeTimeout' : 60,
            'removeCompleted' : false,
            'requeueErrors' : true,
            'onUploadComplete' : function(file) { alert('The file ' + file.name + ' finished processing.'); },
            'onUploadError' : function(file, errorCode, errorMsg, errorString) { alert('The file ' + file.name + ' could not be uploaded: ' + errorString); },
            'onUploadSuccess' : function(file, data, response) { alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data); }
        });
    });
    </script>
</body>
</html>

sys_get_temp_dir() =&gt;的结果的的/ tmp

ini_get('upload_tmp_dir') =&gt;的结果的 /家庭/ ENSEMBL /的public_html / ACCP / uploadTemp

uploadify.php

<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/

// Define a destination
$targetFolder = '/downloadsUploadify/'; // Relative to the root

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

if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
    $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','mp3', 'pdf', 'txt'); // 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.';
    }
}
?>

检查-exists.php

<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/

// Define a destination
$targetFolder = '/downloadsUploadify/'; // Relative to the root and should match the upload folder in the uploader script

if (file_exists($_SERVER['DOCUMENT_ROOT'] . $targetFolder . '/' . $_POST['filename'])) {
    echo 1;
} else {
    echo 0;
}
?>

1 个答案:

答案 0 :(得分:0)

index.php <script>的{​​{1}}内,以及函数uploadify中,您应该添加以下内容:

<?php $timestamp = time();?>

documentation

TargetFolder必须使用直接地址到存储图像的文件夹示例:

  

'FormData' : { 'timestamp': '<? php echo $ timestamp;>', 'token': '<? php echo md5 (' unique_salt '$ timestamp.)>' },