2017-02-14 1 views
0

input 요소에 HTML5 파일 api + webkitdirectory를 사용하려고합니다.webkitdirectory를 사용하여 디렉토리 크기, HTML5 파일 API를 얻는 방법

<input type="file" name="files[]" id="myfile" multiple="" directory="" webkitdirectory="" mozdirectory=""> 

어떻게 자바 스크립트/jQuery를 사용하여, 킬로바이트의 크기()/MB 등) 선택한 폴더/디렉토리를 얻을 수 있습니다.

혼자 힘으로 파악할 수 없으므로 도와주세요.

+0

이 시도 입력의 files 속성을 통해 루프를 선택 할 수 있습니다 후 https://www.html5rocks.com/en/tutorials/file/ 파일 시스템/ –

답변

1

당신은 디렉토리 나 파일이

$('#myfile').change(function(e) { 
 

 
    var totalSize = [].reduce.call(this.files, function(tot, currFile) { 
 
    console.log(currFile.name , ' size=', currFile.size); 
 
    return tot + currFile.size; 
 
    }, 0); 
 

 
    console.log('Total size = ', totalSize) 
 

 
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<input type="file" name="files[]" id="myfile" multiple="" directory="" webkitdirectory="" mozdirectory="">

+0

쿨, 고마워. – raju

관련 문제