Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onsubmit replace any & characters

Status
Not open for further replies.

tyutghf

Technical User
Apr 12, 2008
258
GB
I have a form that is uploading a file but I need to replace the & symbol before the file is uploaded. Is this possible with javascript? I can`t use server side script as the file upload script is an external one so before the form goes off I need to check the file name for any any & symbols and replace with the word and

so

me & my friend.doc becomes
me and my friend.doc

I am using enctype=multipart/form-data in my form for a file if that is important?

Thanks

<form method=post enctype=multipart/form-data>
File to upload : <input type=file name=uploadfile>
<br /><br />
<input type="submit" value="Upload the file &gt;&gt;">
 
Given you cannot change the value of a file input, you'll have to read its value, do any replacing, and write the updated value to a new hidden field.

Of course, this will probably casuse your uploading to fail, so I think you have no choice but to do this server-side. Or rename the files before the user chooses them.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top