0

I've searched on many posts to solve my problem, tried many things and it didn't worked for me. The problem is that I try to upload a file with the demo page provided by the Uploadify plugin (v3.2.1) and it says that the download is complete, but I can't see the file on the server.

First, let's say that I've modified php.ini in my public_html folder to set a path to upload_tmp_dir and session.savepath. I've set both to this : /home/ensembl/public_html/accp/uploadTemp

Then, in the public_html folder again, I've created the .htaccess file and wrote this line into it : suPHP_ConfigPath /home/ensembl/public_html/ to apply the change to all files and subfolders.

All folders have 0755 permissions and all files have 0644.

Is someone seeing what's wrong?

There it goes the code I have now :

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>

Result of sys_get_temp_dir() => /tmp

Result of ini_get('upload_tmp_dir') => /home/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.';
    }
}
?>

check-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;
}
?>
4

1 回答 1

0

index.phpin<script> <?php $timestamp = time();?>和函数 uploadify 中,您应该添加以下内容:

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

文件

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

/5/uploadify/archivos /

于 2013-12-18T15:54:36.563 回答