Dropify insert image dinamically
I , sorry for english i have a materialize modal with a form in this form i have input and an image.
With ajax and json i populate the input field but the image (get by db) isn't show .
This is my code :
- $('.button_edit').click(function() {
- var csrfName = '<?php echo $this->security->get_csrf_token_name(); ?>';
- var csrfHash = '<?php echo $this->security->get_csrf_hash(); ?>';
- $id_cellar = $(this).attr('id');
- $.ajax({
- type: "POST",
- url: "<?=site_url(); ?>index.php/Ajax_call_cellar/return_cellar_edit",
- data: {
- csrfName: csrfHash,
- id_cellar: $id_cellar
- },
- dataType: "json",
- success: function(msg) {
- $.each(msg, function(k, v) {
- $("#edit_" + k).val(v)
- if(k=='pack_img'){
- $("#edit_pack_img1").addClass('dropify');
- $("#edit_pack_img1").attr("data-default-file","<?= base_url(); ?>" + v);
- $('.dropify').dropify();
- }
- })
- console.log(msg);
- },
- error: function() {
- alert("Chiamata fallita, si prega di riprovare...");
- }
- });
- });
If i click on button the image are correctly inserted in data-default-file but i don't see it
- <input id="edit_pack_img1" name="edit_pack_img" type="file" class="dropify" data-max-file-size="0.6M" data-max-height="320" data-max-widht="600" data-default-file="https://lamiabirra.altervista.org/uploads/19/labels/birra_recipe2_v1.jpeg">