Pure ASP Upload 3 Support Product Page

This topic was archived

Remove Filename and Path from File Field

Asked 07 Jun 2007 13:34:21
1
has this question
07 Jun 2007 13:34:21 Mark Williams posted:
Hello,

How can I remove (i.e. blank) the filename and path from a file field immediately after the file in question has popped an error dialog (i.e. it is the wrong file format)? This would force a user to submit only a valid file and therefore not throw the page that details the error again following a post (with the invalid filename still in the file field).

I would appreciate a reply please, as this is my third post and my other two have never been answered!

Regards,

Mark

Replies

Replied 07 Jun 2007 15:49:09
07 Jun 2007 15:49:09 Georgi Kralev replied:
Hi Mark,

As you have already noticed Pure Asp Upload 3 does not have this functionality.
But, if you want to reset your filefield (i.e. blank) you could try the following javascript:
<SCRIPT LANGUAGE="JavaScript"><!--
document.forms[0].reset();
//-->
</SCRIPT>

I hope it will help you.

Regards,

Georgi Kralev

----------------------------------
Support - www.DMXzone.com
Replied 07 Jun 2007 16:36:11
07 Jun 2007 16:36:11 Mark Williams replied:
Thanks for the reply. However, where would I need to put the JavaScript code you mention so it is fired following the pop-up error dialog?

Regards,

Mark
Replied 07 Jun 2007 17:25:23
07 Jun 2007 17:25:23 Georgi Kralev replied:
Hi Mark,

You could put it after your form. For example:
<form action="<%=DMX_uploadAction%>" method="post" enctype="multipart/form-data" name="upld" onSubmit="<%=pau.submitCode()%>;return document.MM_returnValue">
<input name="upflname" type="file" onChange="<%=pau.validateCode()%>;return document.MM_returnValue" />
<input name="" type="submit" />
</form>

<SCRIPT LANGUAGE="JavaScript"><!--
document.forms[0].reset();
//-->
</SCRIPT>

Note: This it will reset the all fields of your form.

If you want to reset only the file field use this line instead document.forms[0].reset();
document.forms[0].upflname.value="";

Just replace upflname with the name of your file field.

Regards,


Georgi Kralev

----------------------------------
Support - www.DMXzone.com
Replied 07 Jun 2007 18:13:01
07 Jun 2007 18:13:01 Mark Williams replied:
Excellent!

Thank you very much for your fast response. I will try it now.

Thanks again!
Replied 07 Jun 2007 18:31:51
07 Jun 2007 18:31:51 Mark Williams replied:
Just tried your code and it does not do anything!

I have even changed the code so it references my form directly...

<SCRIPT LANGUAGE="JavaScript"><!--
document.SupportForm.Attachment.value="";
//-->
</SCRIPT>

This does not work either!

Any chance you could let me have some code that will work please?

Regards,

Mark
Replied 07 Jun 2007 19:31:06
07 Jun 2007 19:31:06 Georgi Kralev replied:
Hi Mark,

Sorry, I have not read your post carefully. From the posts in your other topics I presumed that you want to clear the file field after you return from the error page.

But if you want to clear the file field after the Javascript popup dialog you have to edit the following file: incPU3.js
Find the function checkExtension

Add the following line
field.value = "";

Just after the following line:
alert(getLang(PU3_ERR_EXTENSION,extensions));

Note: The above line appear at too places. Add field.value = ""; after every occurrence.

The resulting code should look like this:
alert(getLang(PU3_ERR_EXTENSION,extensions));
field.value="";

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Any chance you could let me have some code that will work please?<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I have to inform you that all these workarounds and customization comes AS IS (without warranty or support)

Regards,

Georgi Kralev

----------------------------------
Support - www.DMXzone.com
Replied 08 Jun 2007 12:45:45
08 Jun 2007 12:45:45 Mark Williams replied:
Hi

Thanks for reply but unfortunately your solution does nothing! The field is still not blanked (cleared).

Is there something missing?

Regards,

Mark
Replied 08 Jun 2007 14:41:50
08 Jun 2007 14:41:50 Georgi Kralev replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Thanks for reply but unfortunately your solution does nothing! The field is still not blanked (cleared).

Is there something missing?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Well it work just fine on my computer.
Check the following link:
85.187.125.240:7777/public/Flash/Clear_File_Field.htm

Regards,


Georgi Kralev

----------------------------------
Support - www.DMXzone.com
Replied 08 Jun 2007 15:03:53
08 Jun 2007 15:03:53 Mark Williams replied:
Hi again George,

That is strange? Maybe it does not work for IE (you were running Mozilla)?

Here is the code extracted from my incPU3.js file (which is is sitting on my web server)...

alert(getLang(PU3_ERR_REQUIRED));
field.value = "";
field.focus();
return;

alert(getLang(PU3_ERR_EXTENSION,extensions));
field.value = "";
field.focus();
field.uploadOK = false;
return;

alert(getLang(PU3_ERR_EXTENSION,extensions));
field.value = "";
field.focus();
field.uploadOK = false;
return;

I have even tried changing the "" to ' ' but this does not work either.

Have I done something wrong? Sorry to be a pain.

Regards,

Mark.
Replied 08 Jun 2007 15:54:01
08 Jun 2007 15:54:01 Georgi Kralev replied:
Hi Mark,

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>That is strange? Maybe it does not work for IE (you were running Mozilla)?<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

You are right. It looks that for security reasons under IE it is not allowed to modify the value of file field.
Check the following. Instead field.value = ""; try the line:

field.form.reset();

It will reset all fields of the form. But this is the only solution I can think of.

Regards,

Georgi Kralev

----------------------------------
Support - www.DMXzone.com

Reply to this topic