File name input

Discussion in 'Web Design & Coding' started by Khayman, May 31, 2005.

  1. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    Ok, so I want to get the path to a file and send it to the server

    I thought I could used the input type="file" thing because that automatically puts the little browse button on the page, which is neat.

    BUT

    That method sends the whole file to the server and I just want the path and filename.

    So I want the browse button, which pops open a file selection window but not actual send the file

    It seems simple to do, but I'm drawing a blank (except possibly with javascript), anyone?
     
  2. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    Just one question. What good would the filename and path be to the server? Or are you doing some kind of playlist generator or something similar?

    I'm not sure if Javascript could do this at all, I don't think it has access to the file system.
     
  3. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    It doesn't matter, I just want to be able to select a file and then store the path as a string
     
  4. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    I've got an idea... Not sure if it'll work at all, but:

    You use a regular file input in, say, form1. The the submit button doesn't submit, but rather starts a Javascript function which reads the file name from the file input (if this is possible, never tried), writes it into a hidden input in form2, and then submits form2. Sounds doable?
     
  5. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    I've already tried that. I don't like it, isn't very cross browser friendly.
     
  6. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA

    All browsers should be able to support it, other than the older ones, plus it is the only way one can do it. It is IMHO the best solution for now.
     
  7. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    Think i've got it sorted now. Originaly I was using a slight variation which was using a method which only works in IE, but is ok now