|
Rank: Advanced Member Groups: Member
Joined: 6/5/2007 Posts: 76
|
Is it possible to get the file size of the uploading file before it has fully uploaded?
What I want to do it restrict the uploaded file size as much client side as possible, not let them wait ages for the upload just to be told the file is too big.
If so could you point me at an example?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
|
|
Rank: Advanced Member Groups: Member
Joined: 6/5/2007 Posts: 76
|
Is the filesize tested before upload at client side or after upload on server side?
It's important that I somehow test the file before it's fully uploaded.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
There is no way to test the file size on the client side. It's always tested on the server side. The browser first reports the total file size to the server and then starts to transfer the actual file data. As soon as we see total file size is over limit, we abort the upload so the rest is not transferred.
All these are done by the uploader itself, so it has nothing to do with your code.
|
|
Rank: Advanced Member Groups: Member
Joined: 6/5/2007 Posts: 76
|
Thanks
As long as the test is done soon after upload starts so that it can be aborted rather than the whole file being uploaded before being aborted then that's fine.
Am I right in thinking that the file size is reported to the server before all the file is uploaded? How much would be uploaded if any before the file size could be determined? I'm just trying to determin the wait the user would have before being informed the file is too big.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Yes. The file size is in the HTTP headers and the content is in the HTTP form data. The header arrives first --- that's the purpose of having a header.
Note that sometimes other modules before us would read the whole contents before hand anything over to us. For example, if you have a tracing module, it would read the header, read the form data, do some of its own work, then pass the header and data to us. In that case we still get the header first, but somebody before us has already gotten the whole data, so the header arrives us too late. You will see the progress bar freeze and sudenly jumps to 100% in that case. Obviously in this case there is nothing we can do. You will have to remove those modules before us.
|
|
Rank: Advanced Member Groups: Member
Joined: 6/5/2007 Posts: 76
|
With a multi line upload, does the max size refer to the total upload or the individual files being uploaded?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
It's the total size.
|
|