Javascript HTML文件输入框没有';t在onchange事件中触发fileSelect事件和警告-angularJS
我使用HTML文件类型控件来选择和上传文件(使用AngularJS)。我的分数如下:Javascript HTML文件输入框没有';t在onchange事件中触发fileSelect事件和警告-angularJS,javascript,html,angularjs,file-io,Javascript,Html,Angularjs,File Io,我使用HTML文件类型控件来选择和上传文件(使用AngularJS)。我的分数如下: <input id="uploadFile" accept=".csv" type="file" ng-file-select="model.onFileSelect($files)" onchange="angular.element(this).scope().fileNameChanged(this)"> 因此,当我选择任何文件时,会触发fileNameChanged事件,而不是onFi
<input id="uploadFile" accept=".csv" type="file" ng-file-select="model.onFileSelect($files)" onchange="angular.element(this).scope().fileNameChanged(this)">
因此,当我选择任何文件时,会触发fileNameChanged事件,而不是onFileSelect。到目前为止,这一切都很好。但是,如果我选择要上载的相同文件,则不会触发fileNameChanged事件(因为我正在上载相同的文件),但我希望允许用户一次又一次地上载相同的文件。onFileSelect事件从未被激发
有什么办法可以解决这个问题吗?最终,我在HTML中添加了onclick JS事件,如下所示:
<input id="uploadFile" onclick="myFunction();" accept=".csv" type="file" ng-file-select="model.onFileSelect($files)" onchange="angular.element(this).scope().fileNameChanged(this)">
function myFunction() {
//setting value of null of 0th index coz in my case i allow user to upload only single file.
//in case of multiple files, you gotta set value to null of the entire array of file list
//returned by the control
$('#uploadfile')[0].value = null;
return true;
}
函数myFunction(){
//设置第0个索引的null值,因为在我的情况下,我只允许用户上载单个文件。
//如果有多个文件,则必须将整个文件列表数组的值设置为null
//由控件返回
$('#uploadfile')[0]。值=null;
返回true;
}
这样,控件就不会缓存文件名,下次选择同一个文件时,onChange事件将被触发
如果你还面临任何问题,请告诉我
Thx,
Sagar终于成功了,在HTML中我添加了onclick JS事件,如下所示:
<input id="uploadFile" onclick="myFunction();" accept=".csv" type="file" ng-file-select="model.onFileSelect($files)" onchange="angular.element(this).scope().fileNameChanged(this)">
function myFunction() {
//setting value of null of 0th index coz in my case i allow user to upload only single file.
//in case of multiple files, you gotta set value to null of the entire array of file list
//returned by the control
$('#uploadfile')[0].value = null;
return true;
}
函数myFunction(){
//设置第0个索引的null值,因为在我的情况下,我只允许用户上载单个文件。
//如果有多个文件,则必须将整个文件列表数组的值设置为null
//由控件返回
$('#uploadfile')[0]。值=null;
返回true;
}
这样,控件就不会缓存文件名,下次选择同一个文件时,onChange事件将被触发
如果你还面临任何问题,请告诉我
Thx,
Sagar终于成功了,在HTML中我添加了onclick JS事件,如下所示:
<input id="uploadFile" onclick="myFunction();" accept=".csv" type="file" ng-file-select="model.onFileSelect($files)" onchange="angular.element(this).scope().fileNameChanged(this)">
function myFunction() {
//setting value of null of 0th index coz in my case i allow user to upload only single file.
//in case of multiple files, you gotta set value to null of the entire array of file list
//returned by the control
$('#uploadfile')[0].value = null;
return true;
}
函数myFunction(){
//设置第0个索引的null值,因为在我的情况下,我只允许用户上载单个文件。
//如果有多个文件,则必须将整个文件列表数组的值设置为null
//由控件返回
$('#uploadfile')[0]。值=null;
返回true;
}
这样,控件就不会缓存文件名,下次选择同一个文件时,onChange事件将被触发
如果你还面临任何问题,请告诉我
Thx,
Sagar终于成功了,在HTML中我添加了onclick JS事件,如下所示:
<input id="uploadFile" onclick="myFunction();" accept=".csv" type="file" ng-file-select="model.onFileSelect($files)" onchange="angular.element(this).scope().fileNameChanged(this)">
function myFunction() {
//setting value of null of 0th index coz in my case i allow user to upload only single file.
//in case of multiple files, you gotta set value to null of the entire array of file list
//returned by the control
$('#uploadfile')[0].value = null;
return true;
}
函数myFunction(){
//设置第0个索引的null值,因为在我的情况下,我只允许用户上载单个文件。
//如果有多个文件,则必须将整个文件列表数组的值设置为null
//由控件返回
$('#uploadfile')[0]。值=null;
返回true;
}
这样,控件就不会缓存文件名,下次选择同一个文件时,onChange事件将被触发
如果你还面临任何问题,请告诉我
Thx,
萨加尔还没有任何人对此进行更新?即使不是AngularJS,也没有人在jQuery中遇到过类似的问题吗?没有人对此进行过更新吗?即使不是AngularJS,也没有人在jQuery中遇到过类似的问题吗?没有人对此进行过更新吗?即使不是AngularJS,也没有人在jQuery中遇到过类似的问题吗?没有人对此进行过更新吗?即使不是AngularJS,也没有人在jQuery中遇到过类似的问题吗?