jquery - Access Actual File Name -


for file name encoding concerns (users in spain) , other concerns, need manually structure file name uploaded file.

when fine uploader passes information server, code changes target filename (in use case below, "my_name.jpg"). handler.php file saves file name file system, returns new file name in uploadname parameter. working properly.

when return information fine uploader via uploadname parameter, i'm expecting able access new file name in javascript, can make calls store file name database.

the relevant code below:

settings:

 var settings = {     debug: true,     request: {         endpoint: 'ajax/endpoint.php',     },     deletefile: {         enabled: true,         endpoint: 'ajax/endpoint.php'     },     retry: {         enableauto: true     },     callbacks: {         oncomplete: function(id, name, response) {             this.setname(id, response.uploadname);         }     },      autoupload: true,     editfilename: false,     retry: {         enableauto: true     },     resume: {         enabled: true     },     chunking: {         enabled: false     },     session: {         endpoint: 'ajax/initialfiles.php'     },     validation: {         allowedextensions: ['jpg', 'gif', 'png'],         itemlimit: 3,         sizelimit: 5000000     } }; 

code:

$uploaderdiv = $('#fine-uploader');  uploaderobj = $uploaderdiv.fineuploader(settings).on("statuschange", function (event, id, oldstatus, newstatus) {     if (newstatus == 'upload successful' || newstatus == 'deleted') {         var files = uploaderobj.fineuploader('getuploads');         $.each(files, function (i, file) {             if (file.status == 'upload successful') {                 console.log(file);             }         });     } }); 

when uploading file, response server is:

{"success":true,"uuid":"f542c893-920a-4f58-a57f-7bd5d0f45294","uploadname":"my_name-715.jpg"} 

however, console log file info generates:

{ batchid: "98b6a0c0-28ed-466f-8d69-9cea425c20a9" id: 0 name: "karen_book (thumb).jpg", originalname: "karen_book (thumb).jpg", proxygroupid: "acf40500-9c8b-4c6e-a4f6-2542443d458d", size: 5977 status: "upload successful", uuid: "f542c893-920a-4f58-a57f-7bd5d0f45294" } 

given scenario above, how can filename "my_name-715.jpg" in statuschange event?

if you'd access response server, must inside an oncomplete event handler. response json included parameter passed handler. sounds want make request server updated name (from server?). in same handler, should send whatever request required. oncomplete fires when upload request completes, , ondeletecomplete fires when delete request completes.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -