doujiepin5547 2014-10-15 03:22
浏览 50

Uploadify for apk文件不起作用

Im currently using uploadify to upload file. I have upload apk file and upload png file for user to upload. Both im using same way... but why it only work in the png upload ... for apk file upload it did not copy the file to the folder. So I asking for help

PHP CODE:

<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:

//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;
    }

CONTROLLER:

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条回答 默认 最新

  • dongmi1864 2014-10-16 07:37
    关注

    Go xampp->php->php.ini search "post_max_size" and make it post_max_size=100M

    Problem solved =D

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号