如何在valums中获取文件名数组

时间:2015-04-06 05:42:44

标签: javascript php jquery arrays

这是我的js和行动

 public function postyAction()
 {
    $this->_helper->viewRenderer->setNoRender(TRUE);
    // list of valid extensions, ex. array("jpeg", "xml", "bmp")
    $allowedExtensions = array("jpeg","xlsx", "jpg", "gif", "doc", "docx", "xls", "odt", "pdf");
    // max file size in bytes
    $sizeLimit = 6 * 1024 * 1024;
    $f = '../dir/'; //dir to save files
    $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
    $result = $uploader->handleUpload($f);

    // to pass data through iframe you will need to encode all html tags
    echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);

}  
function createUploader(){       
    var UploadedFileNames = [];
    var uploader = new qq.FileUploader({
            element: document.getElementById('file-uploader-demo1'),
            action: '../orders/posty',
            sizeLimit: 10000000, //10MB maximo
            debug:false,
            onComplete: function(id, fileName, responseJson){
                var success = responseJson["success"];
                if(success == true){
                    var files = $(".qq-upload-file").toArray();
                    var UploadedFileNames = [];
                    for ( var i = 0; i < files.length; i++ ) {
                        UploadedFileNames.push( files[ i ].innerHTML );
                    }
                    $( "#filenem" ).val( UploadedFileNames.join( "#" ) );
                }
                //$("#filenem").val(fileName);
            }
        }); 

    }

    // in your app create uploader as soon as the DOM is ready
    // don't wait for the window to load  
    window.onload = createUploader;    

我希望获得一个onComplete()文件数组,以便我可以将它们插入到db中。我的代码获取文件列表的内部html,但较长的文件名似乎是点缀的,因此无法获得真正的文件名。例如e“myverylongdocume..now.doc”而不是“myverylongdocumentnow.doc”例如

0 个答案:

没有答案