Multiple File Upload Is Here!!!

spumonty / 2011-11-22 10:58:09   

I've finally figured out how to select and upload multiple files at the same time. I'm very new to Indexhibit but love what it can do and it's simplicity. One of the main features I needed was multi file upload where you can select multiple files at the same time. During my endeavors to rebuild Indexhibit with a real multiple file upload script, I found a stupid simple fix. This fix is simple enough that anyone can do it, but I take no responsibility for this piece of code or what it may or may not do to your site.

After you add this piece of code you need to use an updated browser when you upload files in the back end. This does not mean that everyone who visits your website needs to use an updated browser, because visitors don't upload files. This should work in FireFox, Chrome and Safari. So if you use Internet Explorer, you're out of luck, as usual. Now on to the fun.

Open an FTP and download this file from your site:
"ndxz-studio/module/exhibits/index.php"

You are going to edit one line then re-upload this file to the same place on your site.

Open the "index.php" file in your favorite text editor. Preferably, use a text editor that shows line numbers, I like Scite or Notepad++.

Scroll down to line 604 and it should read the same as the line below. If it doesn't then you need to find this exact line of code.

  1. $body .= "<input id='my_file_element' type='file' name='filename[]'>n";

You need to add ( multiple='') without the parenthesis, right before the triangle bracket (>). Make sure you use two single quotes at the end of multiple= and not a double quote. The new line should look like the code below.

  1. $body .= "<input id='my_file_element' type='file' name='filename[]' multiple=''>n";

So, multiple='' should be right after name='filename[]' like this, name='filename[]' multiple=''

Now save and upload the edited "index.php" file to the same place on your site. You can overwrite the original "index.php" file with the edited file or you can rename the old file and upload the edited one.

Now go to your site, hold down shift and click the refresh button in your browser. This should refresh your site and recreate your browsers cache. Sign in your your site and create a new exhibit or edit an old one.

To upload multiple files, edit an exhibit then click the "Browse" button underneath the text editor box. When you get the file upload dialog, select a file then hold down ctrl or shift and select another file. Click "OK" on the file dialog and you will see only one file name show up in the file name area. Don't worry about the single file name showing up because when you click "Upload" all the files you selected will be uploaded to your site. After clicking the upload button you should see all of the files you selected in the sorting area. Tada! You now have real multiple file upload.

Vaska A / 2011-11-22 11:07:46   

It's a browser based thing so it won't work for all - it could be really buggy in some.

We already have something even better but it will be awhile before it's released.

People should also be aware that you can only do this with images - if you try to upload something else (because it does not have a filter) it will kill the upload. Images should be under 150kb, as well.

spumonty / 2011-11-22 11:43:53   

Vaska is correct. This hack is based on the availability of this feature in the browser you use. This can be a little buggy for non-image files, but it seems to work well for image uploads. Uploading quantities of images all at once is the only thing I would use multiple file upload for, so this works great.

If you run into problems it's probably because you are trying to upload too many images at once or you could be hitting the upload limit that's set in your "php.ini" file. If you try this and it doesn't work then try using a different browser like FireFox or Chrome.

So, until the new version of Indexhibit comes out, try this little hack and enjoy.

Vaska A / 2011-11-22 12:18:19   

Yeah, you can test the max size for images on your server - but we've found that 150kb is almost always safe. It's a server issue and the amount of raw power that it can throw at resizing images. A 2mb file would almost undoubtedly not work on your typical shared webhosting account. Flickr is a totally different issue - those are billion dollar setups.

It's a simple fix though - I endorse this one because it will also be in the next version.

;)

gf2 / 2011-11-25 15:14:53   

Wow thank you very much for this, can this be applied also to the file manager so that you can simultaneously select multiple files to upload at the same time?

Many thanks,

Gustavo

pernin / 2011-11-28 05:44:50   

Tested spumonty's hack on FF8, Chromium 15, Opera 11 and works well. Several images can be chosen, but just the first of them shows in the upload queue. They all upload, though. Tested on Safari 5, but it borks.

Three out of four is good enough for me, I'd never use more than one browser for administration anyway, and I'd have all major five installed for testing purposes, couldn't care less about testing this in any version of IE

Excellent hack. Thanks spumonty!

This thread has been closed, thank you.