Gargron / fileupload

PHP FileUpload library that supports chunked uploads
MIT License
460 stars 87 forks source link

Chunked file last chuk #10

Closed andheiberg closed 10 years ago

andheiberg commented 10 years ago

I think the resulting file object after processing should contain information about wether the last chunk has been uploaded.

andheiberg commented 10 years ago

Tried to figure it out my self, by doing something like:

    if (substr(strrchr($headers['range'], '-'), 1) == $file['size'])
    {
            // it's full
    }

But the ranges are off by one? I dumped the two and one is one bit larger than the other? Is this consistent?

Gargron commented 10 years ago

It's been a while since I implemented that but I remember that we made a "completed" callback that is fired when a file is fully uploaded (including the case where it's uploaded by chunks).

Yeah, seems to be so. Usage is in the README, goes as follows:

$fileupload->addCallback('completed', function(FileUpload\File $file) {
  // Whoosh!
});