News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Progress bar/circle - Let the browser know the size of the attachment

Started by GigaWatt, May 18, 2018, 08:13:42 PM

Previous topic - Next topic

GigaWatt

Is there a way to get a progress bar/circle when downloading attachments? Or is this a server side setting?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Suki

Do you really mean downloading? if so, every major browser has some kind of "download progress" indicator.

If you really want to show a progress bar you could send the file in chunks and capture those in the client with JS, then put the chunks together and force the file to download. Apart from being prone to errors it just doesn't make much sense to do that when the browser can do it for you.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

GigaWatt

Quote from: Suki on May 18, 2018, 09:03:26 PM
Do you really mean downloading? if so, every major browser has some kind of "download progress" indicator.

Yeah, I know it does, but SMF doesn't report the size of the attachment, so there is no progress bar. It's just downloading, reporting the speed and when the attachment is downloaded, the progress bar goes from 0 to 100% (which, as far as I know, is the case in any download in which the browser doesn't know the size of the downloaded file... I'm guessing SMF doesn't report the size of the attachment ???).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Suki

SMF should indeed show the attachment size (at least it does in 2.1, can't confirm if it does in 2.0.x but I'm pretty sure it does).  If you cannot see the browser progress bar take a look to see if your apache doesn't have the "mod_deflate" ext enable as that might cause the browser to ignore the "Content-Length" header SMF sends.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

GigaWatt

Quote from: Suki on May 20, 2018, 03:25:47 PM
SMF should indeed show the attachment size (at least it does in 2.1, can't confirm if it does in 2.0.x but I'm pretty sure it does).

Yes, it does show the attachment size before downloading, but the progress bar doesn't "respond" to the size, i.e., how much of the file have you currently downloaded (after starting the download). If it's a small file, it doesn't make any difference, but if it's a large file, it does make a difference.

I think a picture will clear things up ;).



It just goes from starting download, to downloading, to finished. The progress indicator goes from 0% to 100%... because the browser doesn't know the size of the file. It is reported in SMF, in the post, I can see the size and the size is correct, but it doesn't report the size to the browser while downloading the attachment. Mind the Unk. text in the progress bar, that's where the size of the file is supposed to be.

This was also the case in the previous version of the forum (1.1.16) and again in 2.0.15. I don't think it's a server issue because with the previous version of the forum, we changed at least 3 hosts, this is (probably) the 4th host we're on since the forum was founded back on 2009 (I can't really be sure, I wasn't an admin back then). So, the same thing is happening on at least 4 hosts... they can't all have the same settings, right ??? ;).

The current version we're on, 2.0.15, wasn't done with upgrades, it was a straight process (1.1.16 --> database conversion --> 2.0.15 from scratch).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

GigaWatt

"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

drewactual

there is a setting in your php.ini that does this... you can also set its increments (i.e. 1% 5%, 10%, ect)... off top of my head i can't recall the setting, but that should be enough to help you find it.   

GigaWatt

Thanks for the tip ;). I'll dig into this deeper, see if I can fix it ;).

EDIT: Another quick question. Can this somehow be coded into SMF? With a mod for example?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Advertisement: