File Upload / Javascript Question
Posted: Tue Oct 05, 2004 11:05 am
I'm trying to restrict my users to only be able to upload PDF files.
This code below works for a single file.
But I am now offering multiple files at once instead of just one and I used the PHP feature of have these files uploaded in an array.
This works just fine for uploading the files. But I want to modify my JS validation to work with the multiple files. When I try to reference in JS:
This is undefined. Does anyone know which variable name in JS can be used with the array style input naming convention?
This code below works for a single file.
Code: Select all
<script>
function valid_form() {
var temp = document.sc_files.sd_file.value;
if (temp.length > 0) {
if (temp.indexOf(".pdf") == -1) {
alert("Support docs must be PDF files.");
return false;
}
}
return true;
}Code: Select all
<tr><td><input type=file size=40 name=sd_filesї]></td></tr>
<tr><td><input type=file size=40 name=sd_filesї]></td></tr>This works just fine for uploading the files. But I want to modify my JS validation to work with the multiple files. When I try to reference in JS:
Code: Select all
var temp = document.sc_files.sd_filesї0].value;