Call success function in field upload

Call success function in field upload

geonovationgeonovation Posts: 5Questions: 3Answers: 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

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Hi Mike,

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

    Allan

  • geonovationgeonovation Posts: 5Questions: 3Answers: 0

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

This discussion has been closed.