2015-05-02, 04:03 AM
I'm looking for a progress bar when I upload attachments.
I've seen other people asking for that but no solution.
The nearest thing for this is to use the Ajax Multiple Upload Attachment, http://community.mybb.com/mods.php?action=view&pid=104
But there is some bugs in it and I don't like some functionality (for example, when you add a file it does not bother to show you the file you selected, it's like nothing happened :/)
I've search for nice an simply way to add this functionality, until now I'm trying to do with this https://www.developphp.com/video/JavaScr...l-Ajax-PHP but no success on my side :/
I've seen similar technique as : http://www.sitepoint.com/html5-javascrip...gress-bar/
or http://phppot.com/jquery/jquery-progress...le-upload/
or this : http://www.w3bees.com/2013/10/file-uploa...s-bar.html
Anybody to try this with me ?
An update if somebody want to help.
Adding the progress bar itself is not a problem using the "post_attachments_add" template and some css, however, updating the progress during the file upload is something else ^^"
In the different php file editpost, newreply and newthread, we can found the call for the upload function if conditions are ok :
Now if we go in functions_upload.php, at the bottom of the file there is the actual upload function :
For the progress bar it should be the "@move_uploaded_file($file['tmp_name'], $path."/".$filename)" that we need to track to update the progress.
In the tutorial that I've read, everytime there is some ajax to do this. My competences are limited and I don't know if it could even be just possible to implement the progress bar by adding some line of code to the actual upload function of MyBB. So if you have an idea, let me know.
I've seen other people asking for that but no solution.
The nearest thing for this is to use the Ajax Multiple Upload Attachment, http://community.mybb.com/mods.php?action=view&pid=104
But there is some bugs in it and I don't like some functionality (for example, when you add a file it does not bother to show you the file you selected, it's like nothing happened :/)
I've search for nice an simply way to add this functionality, until now I'm trying to do with this https://www.developphp.com/video/JavaScr...l-Ajax-PHP but no success on my side :/
I've seen similar technique as : http://www.sitepoint.com/html5-javascrip...gress-bar/
or http://phppot.com/jquery/jquery-progress...le-upload/
or this : http://www.w3bees.com/2013/10/file-uploa...s-bar.html
Anybody to try this with me ?
An update if somebody want to help.
Adding the progress bar itself is not a problem using the "post_attachments_add" template and some css, however, updating the progress during the file upload is something else ^^"
In the different php file editpost, newreply and newthread, we can found the call for the upload function if conditions are ok :
[...]
if($mybb->settings['enableattachments'] == 1 && !$mybb->get_input('attachmentaid', MyBB::INPUT_INT) && ($mybb->get_input('newattachment') || $mybb->get_input('updateattachment') || ($mybb->input['action'] == "do_editpost" && isset($mybb->input['submit']) && $_FILES['attachment'])))
[...]
$attachedfile = upload_attachment($_FILES['attachment'], $update_attachment);
[...]
Now if we go in functions_upload.php, at the bottom of the file there is the actual upload function :
function upload_file($file, $path, $filename="")
[...]
$upload['original_filename'] = preg_replace("#/$#", "", $file['name']); // Make the filename safe
$filename = preg_replace("#/$#", "", $filename); // Make the filename safe
$moved = @move_uploaded_file($file['tmp_name'], $path."/".$filename);
[...]
For the progress bar it should be the "@move_uploaded_file($file['tmp_name'], $path."/".$filename)" that we need to track to update the progress.
In the tutorial that I've read, everytime there is some ajax to do this. My competences are limited and I don't know if it could even be just possible to implement the progress bar by adding some line of code to the actual upload function of MyBB. So if you have an idea, let me know.