HTML5 - Copying image taken from <input> to <img>

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Osiris Dragon
    New Member
    • Aug 2011
    • 10

    HTML5 - Copying image taken from <input> to <img>

    Hi,
    I am trying to take a photo using HTML5 input field, and need to move it to a img tag as below:

    Code:
    <p>Capture Image: <input type="file" accept="image/*" id="f_capture" capture="camera"/> </p>
    
    <img id="imageholder" src="" />
    In Chrome (for testing), when I try to
    $("#f_capture") .val() evaluates to C:\fakepath\pho to.JPG"

    I am not sure how to extract the value from the input field like I would normally do with ordinary <input> items.

    Any help appreciated. Thanks.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    In Chrome (for testing), when I try to
    $("#f_capture") .val() evaluates to C:\fakepath\pho to.JPG"
    looks like it’s working …

    anyways, file inputs implementing the File API can be used as:
    Code:
    var fileName = document.getElementById('f_capture').files[0].name;

    Comment

    Working...