繁体   English   中英

我无法使用Uploadify将文件上传到服务器上

[英]I can't upload files using Uploadify onto my server

尝试将文件上传到服务器时遇到问题。 我正在使用uploadify插件将文件上传到我的服务器上,然后将文件名存储在数据库中。

问题是uplodify行为就像文件已上传,没有错误,但没有任何上传。

我在Windows 2008 R2服务器上运行PHP

以下是我的php代码,用于处理实际上传。

<?php

require("../requires/LDAP_connection.php");
require("../requires/APP_configuration.php");
require("../requires/PHP_generic_functions.php");

//Include connection class
require('../classes/connection.php');
require('../requires/user_authentication.php');  //this file must be placed under the connection class NOT before

define('ROOT_SYS', dirname(__FILE__).'/');

// Define a destination
$targetFolder = '';
$verifyToken = '100';
$actualToken = '';
$fileTypes = array('jpg','jpeg','gif','png');

if(isset($_POST['upload_path'])){
    $targetFolder = $_POST['upload_path'];
}

if(isset($_POST['timestamp'])){
    $verifyToken = md5($_POST['timestamp']);
}

if(isset($_POST['token'])){
$actualToken = $_POST['token'];
}

if(isset($_POST['allowed_extentions'])){

    $types = explode(',', $_POST['allowed_extentions']);

    if(count($types) > 0 ){
        $fileTypes = $types;
    }
}


if (!empty($_FILES) && $actualToken == $verifyToken) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath =  ROOT_SYS . $targetFolder;   //$_SERVER['DOCUMENT_ROOT']
    $new_filename = USER_ID . '_' . time() . '_' . str_replace(" ", "_", $_FILES['Filedata']['name']);
    $targetFile = $targetPath . $new_filename;

    // Validate the file type
    //$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
    $fileParts = pathinfo($new_filename);  //str_replace(" ", "_", $_FILES['Filedata']['name'])

    if (in_array($fileParts['extension'],$fileTypes)) {
        move_uploaded_file($tempFile,$targetFile);
        echo trim($new_filename);
    } else {
        echo 'INVALID';
    }
}
?>

以下是我的JavaScript

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

    <script type="text/javascript">
    $(function() {
        $('#file_upload').uploadify({
            'formData'     : {
                'timestamp' : '<?php echo $timestamp;?>',
                'token'     : '<?php echo md5($timestamp);?>',
                'upload_path': 'add-ons/ticketing_system/uploads/',
                'allowed_extentions': 'jpg,jpeg,gif,PNG,JPG,png,zip,rar,doc,docx,cvs,xls,xlsx,txt'
            },
            'auto' : true,
            'swf'      : '../../includes/uploadify.swf',
            'uploader' : '../../includes/uploadify.php',
            'fileSizeLimit' : '10MB',
            'fileTypeExts' : '*.gif; *.jpg; *.JPG; *.png; *.PNG *.zip; *.rar; *.doc; *.docx; *.cvs; *.xls; *.xlsx; *.txt;',
            'onUploadSuccess' : function(file, data, response) {
                if(data != 'INVALID'){
                    $('#attached_files').append('<input type="hidden" name="attachments[]" value="'+ $.trim(data) +'" />');
                } else {

                    alert('Invalid File Type');
                }
            }

        });
    });
</script>

我究竟做错了什么? 为什么它没有上传任何内容并且也没有给我任何错误?

谢谢

Uploadify具有调试模式,可帮助您解决以下问题: http : //www.uploadify.com/documentation/uploadifive/debug-2/

我通常要寻找的是权限错误...也许是您的身份验证方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM