Welcome Guest Search | Active Topics | Sign In | Register

AJAXUploader: How to Clear Files on Clientside After Error Options
Mark
Posted: Thursday, December 18, 2008 2:56:25 PM
Rank: Newbie
Groups: Member

Joined: 6/12/2008
Posts: 5
Hello all.

I'm trying to clear the upload textbox after a clientside error occurs, specifically a "bad extension" error. After searching the support forums, I came up with the javascript code below.

It seems to clear the text box initially, but if I move my mouse back over the text box, the filename re-appears in the textbox. Is there a better way to handle what I'm trying to do?

Thanks in advance!

Code: JavaScript
function handleError(control, error, message) {
     if (error == "extension_not_allowed") {
          alert(" ... some error message ...");
          var oText=document.getElementById("AJAXUploader1_i_0");
          if (oText) oText.value="";
          var u=eo_GetObject("AJAXUploader1");
          if (u) u.cancel();
     }
}
eo_support
Posted: Thursday, December 18, 2008 3:06:49 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

I am not sure if there is anyway to do that. The file uploader uses standard HTML file input element. For security reasons, while file input element allows JavaScript to read its value, it only allows USER to set its value (by clicking browse button). So you will not be able to use JavaScript to set/reset its value, because otherwise people will be able to write a page to grab any file from people's machine as long as the page is visited.

You do have the option to reload the control though. You can either reload the whole page or use a CallbackPanel/UpdatePanel to do a partial update. That should reset the input values for you.

Thanks!
Mark
Posted: Thursday, December 18, 2008 3:10:53 PM
Rank: Newbie
Groups: Member

Joined: 6/12/2008
Posts: 5
Okay, that makes sense.

Now that I know my options, I can modify accordingly.

Thanks for the quick response!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.