Answer the question
In order to leave comments, you need to log in
Laravel vue axios how to make progress bar?
good afternoon dear experts. tell me how to make laravel vue asios script progress bar.
there is a back controller
public function rasFileRecord($dir, $file, Request $request)
{
$all=count($zap);
foreach ($zap as $z) {
$rasZap = $this->rasZap->createOrUpdateZap($z, $rasFileDb->id);
$this->rasSl->createOrUpdateSL($z, $rasZap->id);
$n++;
Session::pull('progress', $n);
session('progress', $n);
$_SESSION['progress']=$n;
response()->json(['message'=>'test']);
}
}
const CancelToken = axios.CancelToken;
this.source = CancelToken.source();
this.loading = true;
let dir = this.$route.params.dir;
axios
.get(`/api/v1/ras-file-record/${dir}/${nameFile}`, {
cancelToken: this.source.token,
onDownloadProgress: progressEvent => {
let contentLength = event.srcElement.getResponseHeader(
"content-length"
);
let percentCompleted = Math.round(
(progressEvent.loaded * 100) / progressEvent.total
);
/*let data = this.$session.get("progress");
console.log(data);*/
//console.log(progressEvent);
//console.log(percentCompleted);
}
})
.then(resp => {
this.loading = false;
console.log(resp);
})
.catch(err => {
console.log(err);
});
Answer the question
In order to leave comments, you need to log in
Yes, there is another option
https://www.nginx.com/resources/wiki/modules/uploa...
ps if it's not about uploading a file, then you need to make an endpoint that gives progress and hammer there at intervals
Unfortunately, the processing process does not depend on the file upload and does not transfer to the front, dowload, or upload. how to be in that case?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question