Possible duplicate:Clearing <input type = 'file' /> using jQuery
This is my code:
<input ID="fileUpload1" runat="server" type="file" style="width:275px; position:absolute; left:1px"/>
I tried some solutions:
$("input[type='file']").val(''); $('#DivfileUpload').replaceWith("<input class=VWButton ID=fileUpload1 runat=server type=file style=width:275px; position:absolute; left:1px/>");
and many others from the Internet, but fail.
You cannot set the value of the input file for (obvious) security reasons.
If you want to clean it, you need to reset the form in which it is located.
, . ( , , / ASP runat=server, quote, (, )).
runat=server
.val('') (, IE) .
: reset :
$('form').trigger('reset');
(, HTML ):
$('#fileUpload1').replaceWith('<input id="fileUpload1" type="file" style="width:275px; position:absolute; left:1px"/>');
CSS, .
CSS:
#fileUpload1 { width: 275px; position: absolute; left: 1px; }
JavaScript:
$('#fileUpload1').replaceWith('<input id="fileUpload1" type="file"/>');
, , , . , , . , . .;)
$(function() { $('#fileUpload1').val(''); });