Click to See Complete Forum and Search --> : Java Upload Validation & ASP


noogy6608
02-08-2003, 11:51 AM
Please can somebody shed some light on something for me
i do not know the first thing about Java and as far as i can ascertain the script that i have pasted below changes and check the extension before uploading it(part of an ASP Application!)
What happens is it will only allow filenames that are in capital to be uploaded ! How can i change it to load any CASE files ?
it salos check other things like the extension and size
But it is the CASE Problem that is stopping it from working

===========================================
<script language="JavaScript">
<!--
function checkFileUpload(form,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight) { //v2.09
document.MM_returnValue = true;
for (var i = 0; i<form.elements.length; i++) {
field = form.elements[i];
if (field.type.toUpperCase()!= 'FILE') continue;
checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight);
} }

function checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight) { //v2.09
document.MM_returnValue = true;
if (extensions != '') var re = new RegExp("\.(" + extensions.replace(/,/gi,"|").replace(/\s/gi,"") + ")$","i");
if (field.value == '') {
} else {
if(extensions != '' && !re.test(field.value)) {
alert('This file type is not allowed for uploading.\nOnly the following file extensions are allowed: ' + extensions + '.\nPlease select another file and try again.');
document.MM_returnValue = false;field.focus();return;
}
document.PU_uploadForm = field.form;
var re = new RegExp(".(gif|jpg|png|jpeg)$","i");
if(re.test(field.value) && (sizeLimit != '' || minWidth != '' || minHeight != '' || maxWidth != '' || maxHeight != '')) {
checkImageDimensions(field,sizeLimit,minWidth,minHeight,maxWidth,maxHeight);
} }
}
====================================================================

Calmaris
02-11-2003, 03:01 PM
HEY I'M A NEWBIE AT JAVA SCRIPTING MYSELF BUT MY BEST GUESS IS TO DELETE THIS LINE

if (field.type.toUpperCase()!= 'FILE') continue;

TELL ME IF IT HELPS, I'LL THINK I'M A BETTER PERSON FOR IT LOL.

Alex

noogy6608
02-11-2003, 03:06 PM
Nice TRy Alex ! But No cigar!

Sorry your'e the same person !
as you were !

I tried that i seesm the core of the problem is not with that line !

Thanx anyway
Sam

Calmaris
02-11-2003, 03:10 PM
Well I tried, good luck though. That's ok I'm still happy with myself, well until someome comes up with an answer to my Need help I have no clue thread.

Alex