Call success function in field upload

Call success function in field upload

geonovationgeonovation Posts: 3Questions: 2Answers: 0

Hello I'm uploading a file and because I have to make the file smaller because there is bad internet connection in some areas I made a custom ajax upload function.

The uploading works! The return request from PHP is also good. But how can I call the success function so the GUI shows the image that I uploaded?

Adding (method, url, d, success, error) in the 'ajax: function ( fileList)' constructor is not working.

{
label: "Image:",
name: "image",
type: "upload",
display: function ( file_id ) {
return '<img src="'+editor.file( 'files', file_id ).web_path+'"/>';
},
ajax: function ( fileList) {
var fd = new FormData();
var file = fileList.item(0);

               //resize file

                fd.append('upload', file);

                $.ajax({
                    url: 'upload.php',
                    type: 'POST',
                    contentType: false,
                    processData: false,
                    data: fd,
                    cache: false,
                    success: function(response){
                                //uploadXhrSuccess( response );
                                //success(response);
                      },
                 })
            },
            clearText: "Clear",
            noImageText: 'No image'

}

Thanks in advance!

Mike

Answers

  • allanallan Posts: 54,181Questions: 1Answers: 8,456 Site admin

    Hi Mike,

    Editor will trigger a uploadXhrSuccess event when the upload is complete.

    Allan

  • geonovationgeonovation Posts: 3Questions: 2Answers: 0

    Thank you Allen! I moved al the 'resize file' functionality to preUpload and it works!

Sign In or Register to comment.