2011-11-10 3 views
0

나는 blueimp file uploader을 사용하여 웹 공간에 파일을 업로드합니다. 목록의 모든 파일을 상태와 함께 가져 오는 방법은 무엇입니까?업로드 된 모든 파일 가져 오기 blueimp 파일 업 로더

#fileupload div 밖에있는 별도의 버튼이있어서 업로드 된 모든 파일을 사용하여 배열 등을 얻고 싶습니다.

html 코드를 반복하고 파일 이름과 상태를 구문 분석 했습니까? 믿을 수는 없지만이 정보를 돌려주는 함수를 찾을 수 없습니다.

답변

0

나는 내 질문에 언급했듯이 목록의 모든 요소를 ​​반복하고, 삭제 버튼을 찾고 삭제 버튼의 URL에서 파일 이름을 추출하여 해결했습니다.

var files = new Array(); 
$("#fileupload td.delete button[data-type='DELETE']").each(function() { 
    //get the basename of the url: http://abc/def/file.txt --> file.txt 
    var name = $(this).attr("data-url").replace(/\\/g,'/').replace(/.*\//, ''); 
    files.push(name); 
}); 

다른 사람이 더 좋은 해결책이 있습니까? 당신은 downloadTemplate 기능을 설정하고 여기에 당신이 다운로드 한 파일에 필요한 모든 것을 할 수

기능 (O) { } (...) :

+0

내 문제를 해결하지 않았습니까? –

0

(...) downloadTemplateId : 널 (null), downloadTemplate. o.files에 서버의 응답이 있습니다. 파일

0

: script.js

추가 코드 :

add: function (e, data) { 

및 페이지 추가 기능에서 : 밑줄

getFiles__Name(data.files[0].name); 

var files=new Array(); 
function getFiles__Name(name){ 
    files.push(name); 
} 

파일 것 모든 파일의 이름을 포함합니다. 제 의견으로는 이것이 최고의 솔루션이 아닙니다.

2

성공적으로 업로드 콜백이 제공됩니다

var arrNames = new Array(); 

//File uploader 
$('#fileupload').fileupload().bind('fileuploaddone', 
    function (e, data) { 
     //Add names 
     arrNames[arrNames.length + 1] = data.result.files[0].name; 
    } 
); 

arrNames는 업로드 된 파일의 이름을 보유하고

0

이미 FabriGad 아흐메드의 답변을 복용하여 업로드 한 파일의 배열을 얻을 수 있었다 조정할 수 있습니다.

//get the names of the already uploaded files 
if (files){ 
$.each(files, function(index) { 
getFiles__Name(files[index].name); 
}); 
} 

이 나를을 제공합니다 jquery.fileupload-ui.js에서

var img_files=[]; 
function getFiles__Name(name){ 
img_files.push(name); 
} 

난이 (가) 수행 기능에 다음과 같은 추가 : 내보기에서

나는 다음 스크립트를 추가 성공적으로 업로드 된 파일의 배열. 다시 말하지만, 이것을하는 더 좋은 방법이 있다면, 나는 알고 싶습니다.