Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery:如何重置此类型=";文件";_Jquery - Fatal编程技术网

jQuery:如何重置此类型=";文件";

jQuery:如何重置此类型=";文件";,jquery,Jquery,我需要防止用户上传大图像到服务器,并希望使用简单的输入类型=“文件”。使用下面的jQuery,当this.files超过1048000时,如何重置“输入文件” $('.image-file').bind('change', function() { if ( this.files[0].size > 1048000 ) { alert('Image size can not more than 1Mb.'); // going to reset the file

我需要防止用户上传大图像到服务器,并希望使用简单的输入类型=“文件”。使用下面的jQuery,当this.files超过1048000时,如何重置“输入文件”

$('.image-file').bind('change', function() {
  if ( this.files[0].size > 1048000 ) {
    alert('Image size can not more than 1Mb.');
    // going to reset the file            
  }
});

<input type="file" name="photo[]" class="image-file">
<input type="file" name="photo[]" class="image-file">
<input type="file" name="photo[]" class="image-file">
$('.image文件').bind('change',function()){
如果(此.files[0].size>1048000){
警报('图像大小不能超过1Mb');
//要重置文件吗
}
});

请尝试以下代码。但要获得文件大小,可以使用服务器端代码,该代码将返回文件大小

$('#form_id').each(function(){
    this.reset();
});


<input id="fileInput" type="file" onchange="AlertFilesize();" />

}请尝试以下代码。但要获得文件大小,可以使用服务器端代码,该代码将返回文件大小

$('#form_id').each(function(){
    this.reset();
});


<input id="fileInput" type="file" onchange="AlertFilesize();" />

}

确保检查服务器端所有用户提交的数据。不能使用javascript测量文件上载大小,必须首先使用服务器端语言在服务器端提交。您使用的服务器端语言是什么?PHP?pythonPerl?什么?jQuery真的有必要吗?使用纯香草JS,您可以非常明智地执行
this.value=null.Yes此值=null;工作!确保检查服务器端所有用户提交的数据。不能使用javascript测量文件上载大小,必须首先使用服务器端语言在服务器端提交。您使用的服务器端语言是什么?PHP?pythonPerl?什么?jQuery真的有必要吗?使用纯香草JS,您可以非常明智地执行
this.value=null.Yes此值=null;工作!请看一下链接。这是一个工作演示,请看一下链接。这是一个工作演示