Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Upload Question

  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    Sydney, Australia
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Upload Question

    Dear JavaScript Guru,

    I have posted a similar question before, but I just like to ask your suggestion on what to do.

    I want to upload some files to the server, but because user often typed in an incorrect path for the file, we are going to stop them doing that by mocking up an "input field + button".
    (see attached file)

    What I want to perform is to:
    - click the 2nd Browse Button and select the file.
    - the path appears on the input box.
    - upload the File.

    but when I clicked upload, the path disappeared!!! can anyone please help me!
    Attached Files Attached Files

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Even if you'd be successful with it, you should always check on the server if the attached file exists. So why bother with it?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Aug 2002
    Location
    Sydney, Australia
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    or to be simple, if the path is correct in the "input box", and the CGI program is called, will I still be able to upload the file even if I don't use the <input type=file"> ?

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I think the file field is required for upload to be successful
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Two many form tags!

    The problem with that script is that it's not designed for what you want to do, just to provide a 'dummy' file upload button that can be labeled and styled. Try this:
    Code:
    <html>
    <head>
    <title>Uploader</title>
    </head>
    <body>
    <br />
    <form name="LANSA" onsubmit="FileToBeSent.disabled=true">
    <div style="position:relative;height:30px;margin:0px 4px;">
    <input id="dummyfile" type="text" name="FileToBeSent" readonly="readonly" 
    style="position:absolute;top:2px;left:0px;width:148px;font:11px 'comic sans ms';color:darkred;" />
    <input id="realfile" type="file" name="Filename" 
    style="position:absolute;top:0px;left:8px;clip:rect(auto auto auto 142px);" 
    onclick="document.getElementById('dummyfile').value=this.value" 
    onchange="document.getElementById('dummyfile').value=this.value" />
    </div>
    <input type="submit" value="Upload" /> 
    </form>
    </body>
    </html>
    IE doesn't do onclick for file inputs, and moz ignores onchange so, both are covered. Disabled the 'dummy' textfield onsubmit to keep it from cluttering up the data. If this doesn't work in Opera, keep it to yourself. hth

    <edit type="angry">Please remove LINEFEEDS where this editor has broken the code (width:148px;fon<-----).</edit>
    Last edited by cheesebag; 09-25-2003 at 05:08 AM.
    &nbsp;........ another wild guess ........

  • #6
    New Coder
    Join Date
    Aug 2002
    Location
    Sydney, Australia
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks man!
    I think putting a text field with readonly attribute on top of the file field is the only way to go too... really can't think of other way...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •