① jquery如何获取input(file)控件上传的图片名称,即"11111.jpg"
html代码:来
<input name="" type="file" id="fil"/>
Jquery代码:
var str;
$('#fil').change(function(){
str=$(this).val();
})
var arr=str.split('\\');//注split可以用字自符或字符串分割
var my=arr[arr.length-1];//这就是要取得的图片名称
alert(my);
希望对您有帮助!
② jquery怎么点击弹出上传选项
放一个input:file,然后设置为不可见,当点击头像时
$("#头像").click(function(){
$("#input[type=file]").click();
});
③ file控件选择上传文件确定后触发的js事件是哪个
file控件选择上传文件确定后触发的js事件是onchange事件。
④ jquery uploadify上传插件fileExt属性无效,使用时不过滤文件类型。
fileTypeExt→fileTypeExts
⑤ java jquery 点击按钮选择文件,直接传后台处理
使用ajaxfileupload.js插件抄
通过AJAX构造表袭单提交文件
给你一个人家写好的JAVA演示调用地址:
http://www.blogjava.net/sxyx2008/archive/2010/11/02/336826.html
⑥ 怎么在页面上用jquery获取上传文件时的文件名和文件的大小
$("#some").change(function(){
varfile=$('#some').get(0).files[0];
if(file){
varfileSize=0;
if(file.size>1024*1024)fileSize=(Math.round(file.size*100/(1024*1024))/100).toString()+'MB';
elsefileSize=(Math.round(file.size*100/1024)/100).toString()+'KB';
console.log(file.name,fileSize,file.type);
}
});
低版本ie不一定支版持权
⑦ jquery.fileUpload.js文件上传问题
了解,fileuploader方法需要先初始化,然后才能触发上传,并不需要你手动触发change事件
你只需回
html
<form>
file:<inputtype="file"id="file"name="file">
</form>
js
$('#file').on('change',function(){
//这里可以做校验,返回答false就不会触发下面的上传插件,否则就会触发上传
if(!this.value||this.value.indexOf('.jpg')==-1){
returnfalse;
}
});
//初始化上传插件
$('#file').fileupload({
autoUpload:true,//这里为true,则选中文件后就会自动上传
url:'',
done:$.noop,
fail:$.noop
});
⑧ jquery.load.js怎么判上传文件类型
下面是我用jquery写的选中后立马判断选中的文件的类型,不是的话提示,然后清除,对应的可以自己改成纯js形式:
//文件上传文件选择后事件
$(document).ready(function() {
$("input[id^='fileToUpload']").each(
//这里是用了each因为是多文件上传,input的id都是fileToUpload 开头
function() {
$("#" + $(this).attr("id") + "").live('change',function() {
var fileName = $(this).val();
if (fileName != null&& fileName != "") {
//lastIndexOf如果没有搜索到则返回为-1
if (fileName.lastIndexOf(".") != -1) {
var fileType = (fileName.substring(fileName.lastIndexOf(".") + 1,
fileName.length)).toLowerCase();
var suppotFile = new Array();
suppotFile[0] = "jpg";
suppotFile[1] = "gif";
suppotFile[2] = "bmp";
suppotFile[3] = "png";
suppotFile[4] = "jpeg";
for ( var i = 0; i < suppotFile.length; i++) {
if (suppotFile[i] == fileType) {
if (fileName.length > 100) {
alert("文件名长度不能超过100字符");
if (!window.addEventListener) {
document.getElementById(fileName[j]).outerHTML+=''; //IE清除inputfile
}else {
document.getElementById(fileName[j]).value = ""; //FF清除inputfile
}
return false;
}
return true;
} else {
continue;
}
}
alert("文件类型不合法,只支持 jpg、gif、png、jpeg类型!");
if (!window.addEventListener) {
document.getElementById(fileName[j]).outerHTML+=''; //IE
}else {
document.getElementById(fileName[j]).value = ""; //FF
}
return false;
} else {
alert("文件类型不合法,只支持 jpg、gif、png、jpeg类型!");
if (!window.addEventListener) {
document.getElementById(fileName[j]).outerHTML+=''; //IE
}else {
document.getElementById(fileName[j]).value = ""; //FF
}
return false;
}
}
});
});
});
⑨ Js/Jquery获取input file的文件名
Js/Jquery获取input file的文件名:
alert("d:/userAdmin/uploads/20120515_115146.jpg".match(/[^/]*$/)[0]);
document.getElementById("id值").value==$("#id值").val()
上面的例子就是js和jquery的区别,都是通过id值 获取信息。左边内是js写法容,右边是jquery写法
你可以把jquery 理解成js的封装,使js更加简洁,快捷。它把相同的操作封装起来,使用的时候直接调用。
⑩ 求用js和jquery分别实现文件上传时增加删除文件域效果,不要上传能功,只求增删文件域
.......增删文件域,没有必要真的去掉,可以设置为点击时隐藏文件域即可。