上传获取文件大小并显示在文本框中


Uploadify get file size and show in text box

我希望获得文件大小并显示在禁用的文本框中。

我在谷歌上搜索了一下,关于这件事的信息很少。下面是我的代码

在PHP中:

    <div class="inputWrapper">
       <div class="usetitle">* <?php echo Yii::t('labels', 'gameapk'); ?> :
            <div class="div_upload_file_container">
                <div style="position:absolute; margin: 0; padding:0; height:27px">              
                    <input  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>
            <div style="height:50px"></div>
            <div  id="uploaded_file"></div>
       </div>
        <div class="error2"><div id="err_btnUploadFile"></div></div>
     </div>

在JS文件中:

   //file
        $('#btnUploadFile').uploadify({
        'swf': base_url + '/js/plugins/uploadify321/uploadify.swf',
        'uploader': "index.php?r=apk/uploadfile",   
        'folder'    : '/temp',
        'queueID': 'uploaded_file',
        'queueSizeLimit' : 1,
        'progressData': 'speed',
        'removeCompleted': false,
        'width': $('.div_upload_file_container').width(),
        'height': 28,
        'fileTypeDesc': 'Apk Files (*.apk)',
        'fileTypeExts': '*.apk;',
        'fileSizeLimit': '100GB',
        'uploadLimit' : 1,
        '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'){
                console.log (data);
                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 (event,ID,fileObj,data) {
        },
        '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;
    }

obj.filesize是文件大小。。。我说得对吗?如果我是正确的,我应该怎么做才能将obj.filesize从JS获取到我的文本框?

我突然有了一个想法:

$("#appsize").attr('value', obj.filesize);

哈哈感谢=D