Skip to content Skip to sidebar Skip to footer

Uikit Uploader: Getting The Uploaded File

I need to get the uploaded file for pushing it to the list of files, but I'm not able to do it... I hope someone could help me: UIkit.upload('.test-upload', { url: `/api/gridfs/

Solution 1:

The upload component has url option. It's the address of the script, which is used to process your request. The upload plugin only deals with frontend. How do you prepare backend, depends on technology you have used. And there inside the script, you prepare response. It can be json with some parameters.

In php it could look like:

//...upload procedures...set headers as text/json etc
$response = ['success' => true, 'filename' => $upload_data['filename']];
echo json_encode($response);
returntrue;

Then you can check, what goes back in one of the callbacks used by the upload plugin. You place the argument in callback function and try to see with console.log if your json is inside it. Example taken from the docs, and modified a bit:

completeAll: function (arguments) { //added arguments, without it - arguments could be undefined in the line belowconsole.log('completeAll', arguments);

        setTimeout(function () {
            bar.setAttribute('hidden', 'hidden');
        }, 1000);

        alert('Upload Completed');
  }

Post a Comment for "Uikit Uploader: Getting The Uploaded File"