0
<input type="file" id="selectedPhoto" name="profilepicuploader1" 
       onclick="PreviewImage();" accept="image/*" /> 
<img id="profileImage" >

Here is my script:

function PreviewImage() {
  document.getElementById('selectedPhoto').onchange = function(evt) {
    ImageTools.resize(
      this.files[0], 
      {
        width: 150, // maximum width
        height:150 // maximum height
      }, 
      function(blob, didItResize) {
        // didItResize will be true if it managed to resize it, otherwise                
        //false (and will return the original file as 'blob')
        document.getElementById('profileImage').src=window.URL.createObjectURL(blob);
      })
  };
}

The above code is resized the image and show the preview image using document.getElementById('profileImage').src = window.URL.createObjectURL(blob); but I want assign preview image value into input file type plz help me thanks in advance

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Santhosh
  • 1
  • 3
  • Refer this link http://stackoverflow.com/questions/20379027/javascript-reduce-the-size-and-quality-of-image-with-based64-encoded-code – Mani Jun 30 '16 at 11:29
  • You can't `assign preview image value into input file type`. Read this [answer](http://stackoverflow.com/a/1696884/863110). You can use [`formData`](https://developer.mozilla.org/en/docs/Web/API/FormData) and using the request in ajax. And here you can read how to send it [here](http://stackoverflow.com/questions/6974684/how-to-send-formdata-objects-with-ajax-requests-in-jquery) – Mosh Feu Jun 30 '16 at 12:06

0 Answers0