SMF Development > Feature Requests

A better upload system

<< < (2/3) > >>

nend:
What if you press post and the upload is still going? Maybe add a event listener that fires off when the upload is completed. The form will have to wait though for that even listener before it can submit its data.

I been playing though with HTML5's new stuff and last week I believe I started playing with the new features in XMLHttpRequest. Will basically made a form with a progress bar with nominal amount of code edits. Server doesn't have to report the status anymore, allot easier now days, lol.
http://dev.siserver.us/javascript/html5-upload-progress-bar/

IchBin™:
What if you attach something but don't finish posting?

emanuele:

--- Quote from: nend on May 08, 2012, 10:32:11 AM ---What if you press post and the upload is still going? Maybe add a event listener that fires off when the upload is completed. The form will have to wait though for that even listener before it can submit its data.

--- End quote ---
Of course mine was just an explanation, not an implementation. :P

butch2k:
As a side note i managed to code an ajaxified version of the attachment dialog along with multiple drag/drop and copy/pasting. It was no easy task believe me... and it works from IE6 up to chrome.

Here is a quick summary of the issues encountered and the way i dealt with them, maybe it could be of help if someone go through the same stuff.

One of the main issues i encountered was maintening a coherent state whenever an error occurs on submit. Indeed, as designed in SMF, the internal message ids change whenever the post page is refreshed, so you can't rely on this to identify the message to which the attachments are being attached. Remember that at creation time, messages do not have an id yet, so in the attachment table ajax uploaded files are attached to message with id 0.

So i designed an uuid which is carrying over even when the dreaded "someone else posted before you submitted" or "you forgot the subject" error messages appear. Files are uploaded linking to message with id=0 and an uuid (extra column on the attachment table). At submission time in the post2 function (iirc) i update the attachments linked to the uuid i carried over when posting and attach them back to the message id which now exists.

You also need to add some cleanup code to the unload event in case the poster cancels his post after uploading some files.

The code is mixed with some of the ILA mode so clicking on the thumbnail or filename insert either an attach= or attachmini= tag, shift clicking on the thumbnail insert an attachimg tag.

I relied as much as possible on the existing codebase, so i use mostly unmodified versions of the create and remove attachment functions and logic.

butch2k:
I attached a cleanup code to the onbeforeunload event (not on the on unload which is not entirely reliable). Moreover there is a timestamp column added to the attachments table and a batch running every night removing dangling attachments.

One issue with the cleanup code is that you can't rely on an async call, you need an ajax sync call else you request might get cancelled before it execute. I'm actually testing fast synchronous calls using Gearman workers to do the job asynchronously after sending the delete request synchronously.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version