Upload a file with filename already specified

Posted on 2007-08-01
Last Modified: 2007-08-05
How can I upload a file with the filename already specified?  I don't want to have to browse for anything.
Question by:Grant Fullen
    LVL 19

    Assisted Solution

    HTML won't let you do this.

    but, I think you could use javascript to set the value after the page loads.

    give the tag a unique id= to make the javascript easier
    LVL 7

    Expert Comment


    One solution would be to make a html page with a form
    + input button
    + JS, that would fill the input field

    (without submit button)

    I will try some script and get to you latter


    LVL 7

    Accepted Solution

    As i found out:

    It's a security issue. A file-type input can only be populated it's native control, or via keyboard input.

    The value attribute (HTML) and the value property (JavaScript) don't work.

    I found, that you could use value attribute in some browsers, that would have the default file.

    But i didn't find any (try your browsers with this script):

    <form enctype="multipart/form-data" action="upload.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Choose a file to upload: <input name="uploadedfile" type="file" value="C:\Documents and Settings\blabla\Desktop\blabla.txt"/><br /-->
    <input type="submit" value="Upload File" />

    If you find a browser that fills in the file input you just need to write a script to submit your form (if that is what you need).

    LVL 7

    Expert Comment


    The problem is that you cannot specify a default file path for more platforms - on linux there is no C:\ or a:\ thing.

    The only browser that supports value attribute in file input is Opera. But it shows a security pop up with -> do you really want to... note.


    MY IDEA: make a list of files (or one file) above the form and copy -> paste it to the form???
    LVL 7

    Expert Comment

    ok... just remembered something else...

    What kind of file do you need to upload?

    Where do you need to upload it to?

    What is your platform?
    LVL 51

    Expert Comment

    most browser deny to set the value= for <input type="file" ...> for security reason, obviously ..
    LVL 7

    Expert Comment

    I found out you could make a JAVA applet...

    Author Comment

    by:Grant Fullen
    Great, a security flaw makes this ONE thing difficult for me lol.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now