SoFunction
Updated on 2025-04-14

JS code to clear the value of the upload control input(type="file")


var Upload = {
clear: function(id){
var up = (typeof id=="string")?(id):id;
if (typeof up != "object") return null;
var tt = ("span");
= "__tt__";
(tt,up);
var tf = ("form");
(up);
("body")[0].appendChild(tf);
();
(up,tt);
(tt);
tt = null;
(tf);
},
clearForm: function(){
var inputs,frm;
if ( == 0)
{
inputs = ("input");
}else{
frm = (typeof arguments[0] == "string")?(arguments[0]):arguments[0];
if (typeof frm != "object") return null;
inputs = ("input");
}
var fs=[];
for ( var i=0; i<; i++ )
{
if (inputs[i].type == "file") fs[] = inputs[i];
}
var tf = ("form");
for ( var i=0; i<; i++ )
{
var tt = ("span");
= "__tt__" + i;
fs[i].(tt, fs[i]);
(fs[i]);
}
("body")[0].appendChild(tf);
();
for ( var i=0; i<; i++)
{
var tt = ("__tt__" + i);
(fs[i],tt);
(tt);
}
(tf);
}
}