Upload button and Submit at one time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Carlton

    Upload button and Submit at one time

    I have a simple form that does nothing more than let the visitor
    choose an image from their hard drive, and then upload it to the
    server. It doesn't have any other fields than the <input
    type="file"...f ield and, currently, a submit button. It's really
    part of a larger form, but it's called in as an iframe so it's
    technically a stand-alone form.

    My question is, is it possible to submit the form as soon as the image
    is selected, so that they won't have to click the Submit button? I
    started playing with it and can probably make it work with onBlur, but
    that's not exactly right because it still requires that second click
    of the mouse.

    TIA,

    Jason
  • VK

    #2
    Re: Upload button and Submit at one time

    On Jan 5, 2:50 pm, Jason Carlton <jwcarl...@gmai l.comwrote:
    My question is, is it possible to submit the form as soon as the image
    is selected, so that they won't have to click the Submit button?
    From the usability point of view it is a questionable approach: people
    are making wrong selection and it is nicer to leave for the them a
    chance for the last moment correction. Nevertheless you are the boss.
    You may use onchange event handler:

    <form method="POST" action="upload. cgi" enctype="multip art/form-data">
    <input type="file" name="file01" onchange="this. form.submit()">
    <noscript><inpu t type="submit" value="Submit"> </noscript>
    </form>

    Comment

    • Jason Carlton

      #3
      Re: Upload button and Submit at one time

      On Jan 5, 10:50 am, VK <schools_r...@y ahoo.comwrote:
      On Jan 5, 2:50 pm, Jason Carlton <jwcarl...@gmai l.comwrote:
      >
      My question is, is it possible to submit the form as soon as the image
      is selected, so that they won't have to click the Submit button?
      >
      From the usability point of view it is a questionable approach: people
      are making wrong selection and it is nicer to leave for the them a
      chance for the last moment correction. Nevertheless you are the boss.
      You may use onchange event handler:
      >
      <form method="POST" action="upload. cgi" enctype="multip art/form-data">
        <input type="file" name="file01" onchange="this. form.submit()">
        <noscript><inpu t type="submit" value="Submit"> </noscript>
      </form>
      Excellent, thank you!

      FWIW (and just in case anyone reads this later with the same plan),
      the visitor only has one image that they can upload, and it's being
      saved on the server as their username; thus, each time they upload a
      pic it will rename the existing one to username-backup.jpg, and then
      the new one is named username.jpg. This way, I can add a button to
      revert back to the original one if they don't like the new one (which
      would just delete username.jpg and rename username-backup.jpg to
      username.jpg).

      Thanks again,

      Jason

      Comment

      Working...