0

I installed Uploadify UI on my site so I can allow user to upload files to my site. It is working now but the problem is that it uploads files sometimes and sometimes it does not. So I can upload an png file and it will work no problems. but when I upload excel file it will allow some to be uploaded and some it work allow it.

I am not sure what can I check to see what is causing the issue.

I have tried to turn the debuger on 'debug' : true but that did not give me any clues. I also looked at my php logs and there was no error/warnings there.

I am not sure what else I can check but I will apreshiate any type of help with this.

Here is my javascript code to set it up

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

    <script type="text/javascript">
    $(function() {
        $('#file_upload').uploadify({
                'formData'     : {
                'timestamp' : '<?php echo $timestamp;?>',
                'token'     : '<?php echo md5($timestamp);?>',
                'upload_path': 'ticketing_center/',
                'allowed_extentions': 'jpg,jpeg,gif,PNG,JPG,png,JPEG, jpeg,zip,rar,doc,docx,cvs,xls,xlsx,txt'
            },
            'auto' : true,
            'debug' : true,
            'swf'      : '../../includes/uploadify.swf',
            'uploader' : '../../includes/uploadify.php',
            'fileSizeLimit' : '50MB',
            'fileTypeExts' : '*.gif; *.jpg; *.JPG; *.png; *.PNG; *.JPEG; *.jpeg; *.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>

the following is my PHP script

<?php
    $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_FIXED . UPLOAD_DIR . $targetFolder;   //$_SERVER['DOCUMENT_ROOT']
        $targetPath = str_replace( "//", "/", $targetPath);
        $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';
        }
    }
    ?>

Thanks for your time and help

4

1 回答 1

1

我不明白为什么人们会在没有评论帮助您理解原因的情况下投票否决您的问题。但任何帮助其他人的方法都会遇到同样的问题。这是解决方案

我的 php.ini 文件中的配置设置为下限。最大上传文件设置为 2M

转到 php.ini 并找到

  • upload_max_filesize - 设置为 50M

  • post_max_size - 设置为 50M

  • max_execution_time - 设置为 120

  • max_input_time - 设置为 50

重新启动我们的 apache,现在您应该可以上传最大 50MB 的文件了

于 2013-09-01T17:21:59.730 回答