GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.38k stars 4.06k forks source link

Problem occurs from upload image from Assests Manger in grapejs #32

Closed piyalmaduranga closed 7 years ago

piyalmaduranga commented 7 years ago

I have problem with image uploading section in assets manager.I have go though your override method of uploadFile in fileUploader.js. I uploaded selected image in our server. I applied that image uploaded api endpoint in config file.Image is uploaded is fine..but I want to get that image data into frontend. I want to know about what is the response type of image uploading api. because we want response in our side. Is it image data, or image url? Can you help me on this situation.following is code section.that is ajax call how uploading image api in your code.

            $.ajax({
                url         : this.config.upload,
                type        : 'POST',
                data        : formData,
                beforeSend  : this.config.beforeSend,
                complete    : this.config.onComplete,
                xhrFields   : {
                    onprogress: function (e) {
                        if (e.lengthComputable) {
                            /*var result = e.loaded / e.total * 100 + '%';*/
                        }
                    },
                    onload: function (e) {
                        //progress.value = 100;
                    }
                },
                cache: false, contentType: false, processData: false
            }).done(function(data){
                                // what is type of this data.data object.
                target.add(data.data);
            }).always(function(){
                //turnOff loading
            });
artf commented 7 years ago

@piyalmaduranga Indeed is not yet documented, sorry about that. Anyway, the target (a Backbone Collection) could accept an object or an array of objects like this:

target.add([
  {
    src: 'http://img.jpg',
    height: 300,
    width: 200,
  },{
    src: 'http://img2.jpg',
  },
  ...
])
piyalmaduranga commented 7 years ago

Thanks artf..It works fine..

devhameed commented 6 years ago

can you send me complete grapesjs.min.js file and php files please?

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.