我有一个通用文件加载器,如下所示:
<span class="input-group-btn">
<span class="btn btn-default btn-fill btn-file">
Browse<input type="file" id="fileInputs" multiple accept="image/*" onclick="resetprogresss()">
</span>
</span>
我可以使用我的桌面上传多个文件没有问题,但当我尝试在移动设备上使用相同的功能时,我似乎无法选择多个文件。
这是javascript:
var Filenames;
function generateUUID() {
var d = new Date().getTime();
var uuid = 'xxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
return uuid;
};
var MainPath = generateUUID();
var Names = [];
function UploadFiles() {
var SetDir = MainPath;
var fileInputs = document.getElementById("fileInputs");
if ('files' in fileInputs) {
if (fileInputs.files.length == 0) {
alert("Please select a file");
return;
} else {
var file = fileInputs.files[0];
var ar = $("#AutoResumeBoxs").is(":checked");
var chunksize = 20000;
var name = SetDir;
/*
Arguments:
username name used to create subfolders on the server.
files files object from the file input tag.
uploadStartFunction function that receives a file object just before uploading.
progressFunction function that accepts a percent-complete integer value.
doneFunction function called when file is uploaded.
errorFunction function called when an error occurs.
chunkSize size in bytes of each chunk uploaded.
autoResume bool to control auto resuming.
*/
CFUpload(name, fileInputs.files, uploadStarts, progresss, dones, errors, chunksize, ar);
}
}
}
function uploadStarts(thisfile) {
Names.push(thisfile.name);
}
function progresss(percent) {
var p = percent + "%";
$("#lblUPs").text(p);
$("#progressbars").width(p);
$("#progressbars").attr("data-appear-progress-animation", p);
$("#ProgressTabs").text(p);
}
function resetprogresss() {
progresss(0);
}
function dones() {
}
function errors(data) {
}
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
function getCookie(c_name) {
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1) {
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1) {
c_value = null;
}
else {
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if (c_end == -1) {
c_end = c_value.length;
}
c_value = unescape(c_value.substring(c_start, c_end));
}
return c_value;
}
$(document).ready(function () {
$("#urls").hide();
document.getElementById("saveme").disabled = true;
var username = getCookie("username");
});
我使用此library上传文件。任何建议都将不胜感激。
答案 0 :(得分:7)
这取决于您在手机上选择的选择方法,但是,我的原生图库和文件管理器在我的手机上可以正常工作,只需点击并按住您要上传的文件,它就会切换到多选模式:
请注意,有许多jQuery插件用于上传 this one 等文件,因此无需使用纯HTML输入标记。