Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get upload progress using $_FILES? [duplicate]

HTML:

                        <input type="file" value="choose file" name="file[]" multiple="multiple"/><br/>
                        <input type="submit" class="submit" value="confirm" />
                        <input type="hidden" name="uploadFiles" />

</form>

PHP:

if (isset($_POST['uploadFiles'])) {
  $fileCount = count($_FILES["file"]["name"]);
  for ($i = 0 ; $i < $fileCount ; $i++ ) {
      checking......
       move_uploaded_file($_FILES["file"]["tmp_name"][$i],$fileName);
  }
}

Currently I am using the above way to upload the files, I found that the Jquery UI provide the progress bar function but I have to provide the upload status to it. Therefore, what approach I can choose to get the status?

like image 518
user782104 Avatar asked Jun 17 '26 20:06

user782104


1 Answers

My recommendation is to download an already built ajax files upload script and study it a bit as they are quite complex to paste as a reply.

I just had a look at my scripts and it seems that the progress it's actually on the JS side, not in the php.

If you have upgraded to php 5.4 you can use

http://www.php.net/manual/en/session.upload-progress.php

like image 121
aleation Avatar answered Jun 20 '26 09:06

aleation



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!