I am unsure how you plan to preview it? A am quite sure you browser wont show the ai file content as it is not a supported format. Have your read some where that the raw file content from an ai file can be rendered to an img tag?
Feb 13, 2020
33
Level 13
can't preview vector image(.ai)
i try this upload image .ai (vector ) upload done but when i try to preview does not work
here is my code
<div class="input-group">
<span class="input-group-btn">
<span class="btn btn-default btn-file"> Browse… <input type="file" id="imgInp"></span>
</span>
<input type="text" class="form-control" readonly>
</div>
//preview image
<img id='img-upload'/>
here is script file
<script>
$(document).ready( function() {
$(document).on('change', '.btn-file :file', function() {
var input = $(this),
label = input.val().replace(/\/g, '/').replace(/.*\//, '');
input.trigger('fileselect', [label]);
});
$('.btn-file :file').on('fileselect', function(event, label) {
var input = $(this).parents('.input-group').find(':text'),
log = label;
if( input.length ) {
input.val(log);
} else {
if( log ) alert(log);
}
});
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#img-upload').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function(){
readURL(this);
});
});
</script>
Please or to participate in this conversation.