Help! Access Denied

S

soup_or_power

The browser shows the alert but causes an error "access denied" and
fails to set the upload.value to null. Please help!

for(var i=0; i < fileName.length;i++) {
if (fileName.charAt( i) ==' ' || fileName.charAt(i) == '*') {
document.forms[0].upload.value='';
alert("No spaces/wildcards allowed in file names"
+ f.upload.value);

return;
}
}
 
M

Michael Winter

The browser shows the alert but causes an error "access denied" and
fails to set the upload.value to null. Please help!

You cannot set in HTML, nor alter via a script, the value of a file
INPUT element. That would potentially allow a malicious author to upload
any file they wanted from a user's machine.

Mike
 
G

Grant Wagner

The browser shows the alert but causes an error "access denied" and
fails to set the upload.value to null. Please help!

for(var i=0; i < fileName.length;i++) {
if (fileName.charAt( i) ==' ' || fileName.charAt(i) == '*') {
document.forms[0].upload.value='';
alert("No spaces/wildcards allowed in file names"
+ f.upload.value);

return;
}
}

Not to mention that's a pretty inefficient way to check for spaces or
wildcards. Let String#indexOf() do the work for you.

if (fileName.indexOf(' ') != -1 || fileName.indexOf('*') != -1)
{
// fileName contains a space or *
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top