Djohn Rock
Djohn Rock

Reputation: 17

PHP remote file upload progress bar

I want to upload file from frontend to remote server via PHP and progress bar, how could I do this? May be it is possible without installing extra software on frontend and remote servers?

On frontent server a have apache, PHP On remote server a have nginx, PHP-FPM

Upvotes: 0

Views: 565

Answers (1)

Syed Arif Iqbal
Syed Arif Iqbal

Reputation: 1427

you can view this question in details. anyways when you call ajax request from query where is a function called uploadProgress you can call and track the status and percentage on file uploading in server. this function accept four parameters event, position, total, percentComplete

example

$.ajax({
    beforeSend: function() {
         // reset your progress bar here or do anything before making a call to endpoint
    },
    uploadProgress: function(event, position, total, percentComplete) {
        var percentVal = percentComplete + '%';
        $('#progressBar').width(percentVal);
    },
    complete: function(xhr) {
        alert(xhr.responseText);
    }
});

Upvotes: 0

Related Questions