Javascript 如何在数组中获取照片完整url表单
我正在尝试使用jquery通过表单从我的公司拍摄照片。Javascript 如何在数组中获取照片完整url表单,javascript,jquery,html,photo,picker,Javascript,Jquery,Html,Photo,Picker,我正在尝试使用jquery通过表单从我的公司拍摄照片。 -因此,我希望整个URL在一个数组中脱离表单 它适用于Dreamweaver,但不适用于浏览器浏览器,甚至不适用于chrome 最终目标是为残疾人提供一个带有图片/应用程序的日历,但只要我能够通过电话连接 var foto= new Array(); var i=-1; //foto=["toets.png"]; $('#fotouit').append("FOTO UIT"); $('#knop01').click(fu
-因此,我希望整个URL在一个数组中脱离表单
- 它适用于Dreamweaver,但不适用于浏览器浏览器,甚至不适用于chrome
- 最终目标是为残疾人提供一个带有图片/应用程序的日历,但只要我能够通过电话连接
var foto= new Array(); var i=-1; //foto=["toets.png"]; $('#fotouit').append("FOTO UIT"); $('#knop01').click(function(){ $('input:file[name=foto]').each(function(){ //alert($(this).val()); foto.push($(this).val()); foto.forEach( function(){ i++; $('#fotouit').append(foto[i]); $('#fotouit').append('<img src=" '+ foto[i] + ' " width="100" height="100" />'); }); }); })
var foto=new Array(); var i=-1; //foto=[“toets.png”]; $('fotouit')。附加(“fotouit”); $('#knop01')。单击(函数(){ $('input:file[name=foto]')。每个(函数(){ //警报($(this.val()); foto.push($(this.val()); foto.forEach(函数(){ i++; $('fotouit')。追加(foto[i]); $('#fotouit')。附加(''); }); }); })
img
元素的src
中使用,就像您在示例代码中所做的那样。这是对您试图实现的目标的深入解释:
示例:
function handleFiles(files) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
var imageType = /image.*/;
if (!file.type.match(imageType)) {
continue;
}
var img = document.createElement("img");
img.classList.add("obj");
img.file = file;
preview.appendChild(img); // Assuming that "preview" is a the div output where the content will be displayed.
var reader = new FileReader();
reader.onload = (function(aImg) { return function(e) { aImg.src = e.target.result; }; })(img);
reader.readAsDataURL(file);
}
}
函数句柄文件(文件){
对于(var i=0;i
注意:
function handleFiles(files) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
var imageType = /image.*/;
if (!file.type.match(imageType)) {
continue;
}
var img = document.createElement("img");
img.classList.add("obj");
img.file = file;
preview.appendChild(img); // Assuming that "preview" is a the div output where the content will be displayed.
var reader = new FileReader();
reader.onload = (function(aImg) { return function(e) { aImg.src = e.target.result; }; })(img);
reader.readAsDataURL(file);
}
}
- 可以对文件输入使用“多个”属性,以允许使用一个输入选择多个文件
- 您可以使用“文件输入更改”事件立即捕获文件,而无需提供第二个按钮来单击