0

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

Michał Turczyn
  • 32,028
  • 14
  • 47
  • 69
Djohn Rock
  • 17
  • 2
  • Tons of resources out there on this already, please try looking beforehand. e.g. https://youtu.be/pP8MexNb7QM https://stackoverflow.com/q/15410265/2773837 https://stackoverflow.com/q/3586919/2773837 https://stackoverflow.com/q/2704314/2773837 https://stackoverflow.com/q/48819619/2773837 http://php.net/manual/en/features.file-upload.php – Hatchet Jul 10 '18 at 23:47
  • Dude, most of your links are not about uploading file with progress bar to remote server... – Djohn Rock Jul 11 '18 at 00:09
  • What specific issues are you having? Do you have a complete, minimal, and verifiable example? What have you tried that does not work? I posted links since it appears you need a starting point. – Hatchet Jul 11 '18 at 00:11
  • I did't know how to start solving this but now i tried example from your link youtu.be/pP8MexNb7QM and it looks good for me, i need to add percents to progressbar but anyway the main task is solved, thanks! – Djohn Rock Jul 11 '18 at 00:17

1 Answers1

1

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);
    }
});
Syed Arif Iqbal
  • 1,830
  • 12
  • 16