valums AJAX file upload single item fix

Valums ajax upload script is a very nice, clean, and simple to integrate script for uploading files synchronously with ajax (and if it’s not supported in your browser iframes). It’s simply the best implementation I’ve seen, except for one minor glitch.

If you tell it to not allow multiple synchronous file uploads (instead allowing one at a time) it still allows you to drag and drop more than one file at a time, until now. Earlier today at work I programmed in a fix (along with some other modifications to the naming and saving and layout system) that will throw up a message when you try and drop more than 1 file at a time.

The solution is below, note that it starta at line 574

Snipplr: http://snipplr.com/view/50846/valums-ajax-file-upload-single-item-fix/

The key is to replace the line “self._uploadFileList(e.dataTransfer.files);” (originally at line 577) with that simple for and if statement that checks if they have multiple uploads disabled, and if they do and there trying to upload multi files, throws an error message. Pretty simple but I figured I’d post it so nobody else has to fig through the code to find it.

3 Replies to “valums AJAX file upload single item fix”

    1. It’s has no method set up to do that, and the dialog that comes up when you press the button cannot be controlled (as in, they can always select more than 3 files or 1 file, you can’t change that) but the code above can be modified to only allow 3 items to be dropped on it. I guess the question is 3 at a time or 3 total, because I don’t know how you would limit it to 3 total (well I do, modify the php upload script to store the information somewhere (say, the session variable) and then count it off, after three have the upload script always send an error back and refuse to upload).

Leave a Reply to James Cancel reply

Your email address will not be published. Required fields are marked *