Uploadify for apk文件没有用

时间:2014-10-15 03:22:17

标签: php jquery yii

我目前正在使用uploadify上传文件。我上传apk文件并上传png文件供用户上传。两个我使用相同的方式...但为什么它只在png上传工作...对于apk文件上传它没有将文件复制到该文件夹​​。所以我求助

PHP代码:

<div class="div_upload_file_container">
<div style="position:absolute; margin: 0; padding:0; height:27px">              
        <input required="required" style="display:none" id="btnUploadFile" name="btnUploadFile" type="file" />                             
    </div>    
    <div class="div_upload_file_container_inner">                                      
    <div class='word'>

    </div>                         
        <div style='clear:both'></div>
    </div>  
</div>
 

JS文件:

//file
        $('#btnUploadFile').uploadify({
        'swf': base_url + '/js/plugins/uploadify321/uploadify.swf',
        'uploader': "index.php?r=apk/uploadfile",   
        'queueID': 'uploaded_file',
        'progressData': 'speed',
        'removeCompleted': false,
        'width': $('.div_upload_file_container').width(),
        'height': 28,
        'fileTypeDesc': 'Image Files (*.apk)',
        'fileTypeExts': '*.apk',
        'fileSizeLimit': '100MB',
        'itemTemplate': uploadedFileItem(),
        'buttonText' : UPLOAD_FILE,
        'onSelect': function (file) {

        },
        'onUploadStart': function (file) {


        },
        'onUploadSuccess': function (file, data, response) {

            console.log (data)
            $('#' + file.id).html(file.name);

            var obj = JSON.parse(data);
            statusCode = obj.statusCode;

            if (statusCode == '200'){

                var today = obj.today;
                var tmp_folder_with_date = obj.tmp_folder_with_date;
                var filesize = obj.filesize;
                var hashfilename_filename = obj.hashfilename_filename;
                var full_path = obj.full_path;              

                file_cnt ++;

                var html = '';
                html = '<div>';
                html += '<div style="float:left">';
                html += file_cnt + '.';
                html += '</div>';
                html += '<div style="float:left; margin: 0 0 0 10px">';
                html += file.name;
                html += '</div>';
                html += '<div style="clear:both"></div>';
                html += '</div>';

                $('#' + file.id).html(html);

            }

            var params = {
                fileid: file.id,
                fileName: obj.fileName,
                fullSavePath_original: obj.fullSavePath_original,
                fullSavePath_resize: obj.fullSavePath_resize,
                fullSavePath_tobesave: obj.fullSavePath_tobesave,
                fullSavePath_tobesaveURL: obj.fullSavePath_tobesaveURL,
                filesize: obj.fileSize,
                fullPath_TempFolder: obj.fullPath_TempFolder,
                orientation: obj.orientation,
                tobesave_file_width: obj.tobesave_file_width,
                tobesave_file_height: obj.tobesave_file_height,
                todayTempFolder: obj.todayTempFolder
            };

            DisplayNewUploadedPhotos(params);

        },
        'onUploadComplete': function (file) {

        },
        'onCancel': function (file) {

        },
        'onDialogClose': function (queueData) {

        },
        'onInit': function (instance) {

        },
        'onQueueComplete': function (queueData) {

        },
        'onClearQueue': function (queueItemCount) {

        }
    });

    function uploadedFileItem() {

        var html = '';      

        html = '<div id="${fileID}" class="fileUploadedItem">';     
        html += '<div style="margin:10px 0 0 0"></div>';
        html += '<div class="uploadify-progress-bar"></div>';
        html += '<div style="margin:10px 0 0 0">';
        html += '<center><a href="#">Cancel</a></center>';
        html += '</div>';
        html += '</div>';

        return html;
    }

控制器:

public function actionUploadFile()
{               

    if (isset($_FILES['Filedata']['tmp_name']) && is_uploaded_file($_FILES['Filedata']['tmp_name'])) {                      

        $today = date("Ymd");     

        $slash = Yii::app()->params['slash'];   
        $tmp_folder = Yii::app()->params['tmp_folder'];
        $tmp_folder_with_index_file = $tmp_folder . $slash . 'index.html';
        $tmp_folder_with_date = Yii::app()->params['tmp_folder'] . $today;      

        if (!is_dir($tmp_folder_with_date)){
            mkdir($tmp_folder_with_date, 0755);                     
            copy($tmp_folder_with_index_file, $tmp_folder_with_date . $slash . 'index.html');
        }                   

        $filesize = sprintf("%u", filesize( $_FILES['Filedata']['tmp_name'] )); 

        $hashfilename_filename = md5(time() + 1) . '.apk';  

        $full_path = $tmp_folder_with_date . $slash . $hashfilename_filename;

        if (!move_uploaded_file ($_FILES['Filedata']['tmp_name'], $full_path)){             
            $result['statusCode'] = "500";  
            echo json_encode($result);      
            die();
        }                       

        $result['statusCode'] = "200";          
        $result['today'] = $today;  
        $result['tmp_folder_with_date'] = $tmp_folder_with_date;        
        $result['filesize'] = $filesize;    
        $result['hashfilename_filename'] = $hashfilename_filename;  
        $result['full_path'] = $full_path;      

    }else{
        $result['statusCode'] = "400";          
    }       

    echo json_encode($result);      
    die();
}

1 个答案:

答案 0 :(得分:0)

go xampp-&gt; php-&gt; php.ini搜索“post_max_size”并将其设为post_max_size = 100M

问题解决= D