我正在用VS2012和Javascript开发一个地铁应用程序
我想重置我的文件输入的内容:
<input type="file" id="uploadCaptureInputFile" class="win-content colors" accept="image/*" />
我该怎么做呢?
我正在用VS2012和Javascript开发一个地铁应用程序
我想重置我的文件输入的内容:
<input type="file" id="uploadCaptureInputFile" class="win-content colors" accept="image/*" />
我该怎么做呢?
当前回答
getElementById (uploadCaptureInputFile”)的文件。价值;
其他回答
也适用于动态控制。
Javascript
<input type="file" onchange="FileValidate(this)" />
function FileValidate(object) {
if ((object.files[0].size / 1024 / 1024) > 1) { //greater than 1 MB
$(object).val('');
}
}
JQuery
<input type="file" class="UpoloadFileSize">
$(document).ready(function () {
$('.UpoloadFileSize').bind('change', function () {
if ((this.files[0].size / 1024000) > 1.5) { //greater than 1.5 MB
$(this).val('');
alert('Size exceeded !!');
}
});
});
getElementById (uploadCaptureInputFile”)的文件。价值;
有许多方法,我将建议去参考附件输入。
<input
id="image"
type="file"
required
ref={ref => this.fileInput = ref}
multiple
onChange={this.onFileChangeHandler}
/>
在提交后清除值。
this.fileInput.value = "";
我在ng2-file-upload中遇到过angular的问题。如果你正在寻找angular的解决方案,请参考下面的代码
HTML:
<输入type=“文件”/>
组件
import {Component, OnInit, ElementRef, ViewChild} from @angular/core;
@ViewChild (activeFrameinputFile) InputFrameVariable: ElementRef;
this.frameUploader.onSuccessItem =(项目,响应,状态,头)=> {
`this.`**InputFrameVariable**`.nativeElement.value = '';`
};
我用来做vuejs
<input
type="file"
ref="fileref"
@change="onChange"/>
this.$refs.fileref.value = ''