Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

upload preview image jquery

// <input type="file" accept="image/*" id="img-input">
// <img id="preview"/>
function readURL(input) {
      if (input.files && input.files[0]) {
          var reader = new FileReader();
          reader.onload = function(e) {
          $('#preview').attr('src', e.target.result);
          }
          reader.readAsDataURL(input.files[0]);
      } else {
          $('#preview').attr('src', '');
      }
    }

  $("#img-input").change(function() {
    readURL(this);
  });
Comment

image upload using jquery ajax

var formData = new FormData();
formData.append('file', $('#myfile')[0].files[0]); // myFile is the input type="file" control

var _url = '@Url.Action("UploadFile", "MyController")';

$.ajax({
    url: _url,
    type: 'POST',
    data: formData,
    processData: false,  // tell jQuery not to process the data
    contentType: false,  // tell jQuery not to set contentType
    success: function (result) {
    },
    error: function (jqXHR) {
    },
    complete: function (jqXHR, status) {
    }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: collapse uncollapse jquery 
Javascript :: nuxt emit 
Javascript :: react function being called every minute 
Javascript :: javascript round to 2 decimals 
Javascript :: cannot use import statement outside a module 
Javascript :: javascript cancel timeout 
Javascript :: reverse words in a string javascript 
Javascript :: preload javascript 
Javascript :: axios post 
Javascript :: remove char from string js 
Javascript :: jquery fade out 
Javascript :: countdown timer in react js 
Javascript :: let in javascript 
Javascript :: jquery check if input is empty 
Javascript :: how to run js before submit html 
Javascript :: js map array to dictionary 
Javascript :: react js loop through array of objects 
Javascript :: check jquery page 
Javascript :: display content in a modal react 
Javascript :: javascript split sentence into words 
Javascript :: how hide .html in url 
Javascript :: mv multiple directories 
Javascript :: javascript password hashing 
Javascript :: json placholder 
Javascript :: how to send enter event to input field jquery 
Javascript :: js is of type array 
Javascript :: node module es6 
Javascript :: javascript how to sort alphabetically 
Javascript :: aos initial configuration vue 
Javascript :: formik react native 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =