let finalFile $("#uploadAttachment").on('change', function(){ let uploadedFile = $("#uploadAttachment").val(); let userId = localStorage.getItem('userId'); var formData = new FormData(); formData.append("file", event.target.files[0]); formData.append("uid", userId); var file = this.files[0]; var fileType = file["type"]; var validImageTypes = ["image/gif", "image/jpeg", "image/png"]; if ($.inArray(fileType, validImageTypes) < 0) { // invalid file type code goes here. errorBlock("#error_block","please select proper image file !"); $("#uploadAttachment").val(""); } else{ $.post({ url: api_url + "application/uploadFileForAuditionApplication", contentType: false, processData: false, enctype: 'multipart/form-data', data : formData, success : function(response) { finalFile = response.payload; }, error: function (error) { console.log(error); } }); } })
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter