Jump to content

Reset Input File Value


killboy

Recommended Posts

Hi there.I'm working with and input type "file". After making all the operations uploading with the server script language, I need the input value to reset. This is the input:

<input name="file_upload" id="file_upload" type="file" class="label" size="60">

When I finish with the upload, via JavaScript I say

document.getElementById("file_upload").value="";

I works fine on Firefox, but IE doesn't want to do it. Anyone could tell me how to do this on IE?Thanks.

Link to comment
Share on other sites

JavaScript isn't actually supposed to be able to modify the value attributes of inputs of type file for security reasons (e.g. file_input.value = "C:\sensitive.doc"; form.submit() :) ). However, you could replace the input with completely new HTML, e.g.

<div id="file_con"><input name="file_upload" id="file_upload" type="file" class="label" size="60"></div>

document.getElementById("file_con").innerHTML = "<input name=\"file_upload\" id=\"file_upload\" type=\"file\" class=\"label\" size=\"60\">";

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...