JavaScript Displaying an image added via file upload using Javascript

Need to display an image added to the document via file upload, before sending it to the server.

Have the following markup:

<body>
    <div id="image-container">
        <h2>Image Chosen form the File System:</h2>
        <!-- Chosen image is displayed here, in an image tag via Javascript -->
    </div>
    <label for="image-input">Select an Image from Your File System to Display Above</label>
    <input id="image-input" type="file" />
    <input type="submit" value="Display Image Chosen" />
</body>

The chosen image should be displayed in the div when the user clicks on the button.

Answer:1

DO SOMETHING LIKE THIS..

JS code below:

function readURL(input) {

if (input.files && input.files[0]) {
    var reader = new FileReader();

    reader.onload = function (e) {
        $('#blah').attr('src', e.target.result);
    }

    reader.readAsDataURL(input.files[0]);
}

}

$("#imgInp").change(function(){
  readURL(this);
});

and the associated HTML:

<form id="form1" runat="server">
  <input type='file' id="imgInp" />
  <img id="blah" src="#" alt="your image" />
</form>

CHECK THIS FIDDLE http://jsfiddle.net/LvsYc/

Answer:2

I'm using Tiny MCE 4 for users posting on my website. It works very well, but the problem is that when a users puts an image in Tiny MCE, and changes its size, it generates the following line: <...

I'm using Tiny MCE 4 for users posting on my website. It works very well, but the problem is that when a users puts an image in Tiny MCE, and changes its size, it generates the following line: <...

  1. inline image with text
  2. inline image in email
  3. inline image with text css
  4. inline image in css
  5. inline image with text html
  6. inline image in html email
  7. inline image in
  8. using inline image in html
  9. image inline with text bootstrap
  10. image inline with text latex
  11. image inline with paragraph html
  12. image inline with text word
  13. image inline with text powerpoint
  14. image inline with text html css
  15. image inline with text wordpress
  16. sending inline image email using java

I'm looking to convert a basic click function into an AJAX call, but I am not sure how to do so with appended responses I have that are sent from my php script. How could I do this? I have the ...

I'm looking to convert a basic click function into an AJAX call, but I am not sure how to do so with appended responses I have that are sent from my php script. How could I do this? I have the ...

  1. jquery basic click function

I’m trying to change the background colors of a highcharts scatter plot. I can easily change the color of the section with this code below. However, I need change the background to more than one color....

I’m trying to change the background colors of a highcharts scatter plot. I can easily change the color of the section with this code below. However, I need change the background to more than one color....

  1. changing color background in photoshop
  2. changing color background css
  3. changing color background video
  4. changing color background
  5. changing color background html
  6. change color background instagram story
  7. change color background online
  8. change color background illustrator
  9. change color background photo online
  10. change color background image css
  11. change color background instagram
  12. change color background android studio
  13. change color background on text messages
  14. change color background photo
  15. change color background indesign
  16. change color background premiere pro
  17. change color background svg
  18. change color background ig story
  19. change color background app
  20. change color background maya

Why my code is unable to run and brower's console is producing error "JQuery is not defined" even though I am en-queuing my JavaScript file into the plugin properly. As per source code, JQuery ...

Why my code is unable to run and brower's console is producing error "JQuery is not defined" even though I am en-queuing my JavaScript file into the plugin properly. As per source code, JQuery ...

  1. wordpress uncaught referenceerror jquery is not defined
  2. wordpress uncaught referenceerror tinymce is not defined
  3. wordpress uncaught referenceerror $ is not defined
  4. wordpress uncaught referenceerror grecaptcha is not defined
  5. wordpress uncaught referenceerror columns is not defined
  6. wordpress uncaught referenceerror mejs is not defined
  7. wordpress uncaught referenceerror ajaxurl is not defined
  8. wordpress uncaught referenceerror google is not defined