I have an area where I upload several images and the code worked well until someone started uploading images with single quotes. Example: Mike's Pictures.jpg
So I tried to correct it in PHP however thats an issue in itself so I am relying on JAVA to verify there are no special characters in the file name prior to uploading the images instead.
All of my document.PostForm checks work except this one on the array area shown below. The Java does work in other parts of my sites code. Just not with the image array.
It appears the Java script never matches to the array and I cant seem to get the check for special characters to happen.
There is No error output. I am a PHP programmer and Im sure its a simple fix I just need a second set of eyes to tell me where the issue is.
CODE
I have tried doing stuff like images[0], images[1] etc with no luck using document.PostForm.images[0].length
My JAVA Check for Special Characters.
var iChars = "!@#$%^&*()+=-[]';,/{}|<>?";
for (var i = 0; i < document.PostForm.images[].length; i++) {
if (iChars.indexOf([b]document.PostForm.images[][/b].charAt(i)) != -1)
{
document.write("Image file name containts special characters. \n These are not allowed.\n Please rename the files and try again.");
return false;
}}
My ARRAY IN HTML AREA OF SITE
<tr>
<td align=right valign=top>Images:</td>
<td>
<input type=file name="images[]"><br>
<input type=file name="images[]"><br>
<input type=file name="images[]"><br>
<input type=file name="images[]"><br>
</td>
</tr>
This post has been edited by Mitchell2038: 9 May, 2008 - 09:51 AM