dropify icon indicating copy to clipboard operation
dropify copied to clipboard

Can I change data-default-file with jQuery ?

Open mecjos opened this issue 8 years ago • 17 comments

I want to edit table element which includes image file. To do this, first I get existing file name with;

existingImage = $("#imgElement").attr("src");

then I try to change input element data-default-file attribute with;

$("#inputImageElement").attr("data-default-file", existingImage);

In that way, I can see data-default-file when I inspect element but I can't see on screen.

mecjos avatar Jul 13 '17 08:07 mecjos

I use

dropify.dropify({
           "defaultFile": "full path file",
            "messages": {
                    default: 'Arrastre un archivo o haga clic aquí',
                    replace: 'Arrastre un archivo o haga clic en reemplazar',
                    remove: 'Eliminar',
                    error: 'Lo sentimos, el archivo demasiado grande'
                }
            });

roberto-slopez avatar Aug 05 '17 16:08 roberto-slopez

@JackZeled0n Sorry, I updated my comment

roberto-slopez avatar Jan 09 '18 22:01 roberto-slopez

My team & me use angular, our solution were `

$(document).ready(function(){
    var nameImage =  'full path file';
    $('.dropify').dropify({
        defaultFile: nameImage ,
    });
});

`

JackZeled0n avatar Jan 10 '18 05:01 JackZeled0n

How can I binding image by Base64?

hanhduykaka avatar Jul 27 '18 11:07 hanhduykaka

@hanhduykaka Are you using any specific function for making the Base 64? I think something, you can get the image wherever you have it and you can decode for putting on defaultFile=your-image-decode.format(jpg,png) the property by Dropify.

JackZeled0n avatar Jul 27 '18 20:07 JackZeled0n

@JackZeled0n : You mean I must using decode base64 before using defaultFile and using when I want to binding code from the database?

hanhduykaka avatar Jul 30 '18 04:07 hanhduykaka

@hanhduykaka Yes, you could use it for making the encode and decode the url of the image that you want put on the property. I don't understand so good that you want to say with

I want to binding code from the database

JackZeled0n avatar Jul 30 '18 16:07 JackZeled0n

@JackZeled0n : I have a form and using Dropify for upload Avatar. So when I get an API from backend and the data for Image is base64. I'm trying decode URL to blob but still not working!

hanhduykaka avatar Jul 31 '18 08:07 hanhduykaka

@JackZeled0n I tried your solution. It didn't work. My dropify is in a edit modal form.

mecjos avatar Sep 04 '18 19:09 mecjos

@mecjos can you show how you do?

JackZeled0n avatar Sep 05 '18 05:09 JackZeled0n

@JackZeled0n I do it as follow.

$(document).ready(function() {
    $(document).on('click', '.editButton', function() {
       
        $.ajax({
            type: 'GET',
            url: 'projects/' + editProjectId + '/edit',
            dataType: 'json',
            error: function (data) {
                console.error('Error:', data);
            },
            success: function (response) {
                var nameImage = response.imagName
                  $('.dropify').dropify({
                       defaultFile: nameImage ,
                  });
            }
        });
}

mecjos avatar Sep 05 '18 12:09 mecjos

What brings the response? Make a console log and show us the mistake

console.log(response.imagName);

You have to be sure you get the good response from the request.

JackZeled0n avatar Sep 10 '18 01:09 JackZeled0n

@mecjos Any Success buddy. I am Stuck at same issue , Please tell me how did you solve this problem :)

ghost avatar May 13 '19 05:05 ghost

@akshaysalekar108 : defaultFile: blobFunction() ,

You can create a function: blobFunction() and return decode URL to blob from your base64

like this

hanhduykaka avatar May 14 '19 10:05 hanhduykaka

@hanhduykaka i'm trying this right now, but didn't solve my issue

developerabdan avatar Feb 17 '20 07:02 developerabdan

@hanhduykaka thanks dude, it's work fine

SkinnyCoders avatar Jun 11 '20 09:06 SkinnyCoders

you're welcome

hanhduykaka avatar Jun 12 '20 08:06 hanhduykaka