[英]How to upload a file into a specific location in the Google Drive using the JS API?
[英]How to upload a file to a specific location in the local machine using HTML and Javascript
我是javascript新手,我的用例之一是將文件從本地計算機上載到同一計算機中的選定目錄。
HTML代碼:
<!DOCTYPE html>
<html>
<body>
<h3>File Upload to the selected location</h3>
<form action="">
<input type="file" id="files" name="files[]" multiple />
<output id="list"></output>
</form>
<script src="testing.js"></script>
<br><br> Local Path (C:\Users\UserName\Documents\) <input type="checkbox" value="TestPurpose">
</body>
</html>
JS代碼:
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// files is a FileList of File objects. List some properties.
var output = [];
for (var i = 0, f; f = files[i]; i++) {
output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a', ') - ',
f.size, ' bytes, last modified: ',
f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a',
'</li>');
}
document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
因此,一旦我從本地計算機上載文件並選中該復選框,上載的文件應移到html復選框之外的指定位置。 有人可以幫我嗎?
出於安全原因,您無權訪問用戶的文件系統。 該文件只能作為與用戶直接交互(確認下載)的結果而下載,並且只能在每次手動下載過程中或在默認下載目錄(取決於瀏覽器設置)中用戶選擇的目錄中下載。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.