Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vgraphr's avatar

problem with show progress bar when use laravel api

when i use laravel web level for upload, that return progress percent to show in progress bar with javascript,

/ UPDATE /

i use vuejs and axios to frontend

axios.post(SaveUrl, formData,{ onUploadProgress: progressEvent => { var percentCompleted = Math.round( (progressEvent.loaded * 100) / progressEvent.total ); if(percentCompleted > 0){ this.queryPercentUps = false; } this.PercentUps = percentCompleted; } }).then(function (res) {

but when use api level, not return anything to onUploadProgress function !

Is there a solution?

0 likes
4 replies
vgraphr's avatar

Thanks man, but problem is not in Library, that reason is work on web level, so its need to change api settings to return progress percent, but i don know where is it !

vgraphr's avatar

i found problem, but i dont know why ! i create PWA app, so i need offline work, requests handle by workbox, when deactivate workbox, progress again work

Is there a solution for this ?

martinbean's avatar

@vgraphr You’re only going to get “upload progress” if you actually hit an API endpoint that returns multiple models from which progress can be calculated. A single HTTP request isn’t going to return this information. You make the request, the request then returns a response.

Upload progress is usually found in libraries and APIs that upload files using chunks. This is because each chunk of a file is uploaded using a separate HTTP request. If you have an API that uploads files in 1MB chunks and you use a library to upload a 100MB file, then this will issue 100 HTTP requests, and the library can calculate that for each successful HTTP request, it has uploaded 1% of the file and can report upload progress accordingly. This is how the AWS JavaScript SDK works, for example.

Please or to participate in this conversation.