Help! Access Denied

Discussion in 'Javascript' started by soup_or_power, May 3, 2005.

  1. 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;
    }
    }
     
    soup_or_power, May 3, 2005
    #1
    1. Advertisements

  2. 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
     
    Michael Winter, May 3, 2005
    #2
    1. Advertisements

  3. Thank you Michael!
     
    soup_or_power, May 4, 2005
    #3
  4. soup_or_power

    Grant Wagner Guest

    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 *
    }
     
    Grant Wagner, May 6, 2005
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.