Ajaxorized

Multiple Upload Solution; Using Javascript, Flash and PHP

October 19, 2007

Thanks for the introduction Willem and hi all! Willem asked me to write some posts on additional topics like Flash, Actionscript and so on. I hope you will enjoy some of my findings, codes, tips or stories.

For my first contribution i'd like to start sharing a script i wrote a few months ago.

A problem i often encouter is that people, often customers, would like to upload multiple files all together, instead of, what you often see, one file at the time. Of course a very simple solution is to put multiple HTML upload fields on a page, but obviously we could think of a better solution. There are many alternatives on the internet, but most of them aren't customizable and as a real webdeveloper, i would like to create my own solution of course. That is why i created a solution combining three popular webtechnologies; Javascript, Flash and PHP; Javascript constrols the visual aspects, while Flash in combination with PHP handles the upload process.

Since Flash 8, the possibility to communicate between Flash and Javascript is improved, so you can communicate easily using the Flash's ExternalInterface API. With this you can call javascript functions from Actionscript and pass any number of arguments of any data type and vice versa!

To see a working example of my multiple upload solution, click here (no files will be actually uploaded).

I also helped willem out with the design and think we came up with a nice look for this weblog. As you can see at the top we included a menu and added the page 'projects'. I hope we will be able to give this page some content and if i improved my multiple upload script, i will add this as a project. Untill then, you can download the source of this first version here.

Add to: del.icio.us Reddit Slashdot Digg Facebook Technorati Google StumbleUpon Windows Live Yahoo
topFiled under: Javascript, PHP, Flash, Actionscript | martijn @ 8:17 pm |

11 Comments

RSS feed for comments on this post. TrackBack URL

  1. Hi there; wonderfull and interesting script you’ve got there.
    It works beautifully under FF on Mac, but with tests on FF and IE6 under XP it did nothing. Is there something wrong with the script?

    Comment by S. Witte — November 29, 2007 @ 3:44 pm

  2. Hi S. Witte,
    Can you give more specific information on what is not working? I did some tests and it does work in FF/IE with XP.

    Thanks,

    Comment by Willem — November 29, 2007 @ 5:37 pm

  3. Hi S. Witte, remember that this is just a simple demo. I am planning to make it much more extensive, so every help is welcome. Especially in the form of cross-browser tests :) thanks in advance!

    Comment by martijn — November 29, 2007 @ 5:42 pm

  4. O.k., can we continue via e-mail (and in dutch? ;) )

    Comment by S. Witte — November 30, 2007 @ 11:02 am

  5. We zouden graag meewerken om dit script goed doorgetest te krijgen - en willen onderzoeken of het bruikbaar is in Image*After.
    Aanwezige testplatforms: Apple OSX10.4, WinXP Home, WinXP-Pro, Linux.
    Oh ja, en een bezoekers-potentieel van zo’n 8000 per dag.:)
    Kortom, neem a.j.b. even contact op?
    switte@xs4all.nl, of tothecoolguys@imagefater.com

    Met groet!
    Stefan

    Comment by S. Witte — December 1, 2007 @ 7:25 pm

  6. Hi,

    Great little script! I’ve used it on my site and it works perfectly in everything except Firefox. The flash uploader does not seem to pass the cookie properly. The end result is that a new cookie session is created which means my error trapping stops this (need to use the original cookie to assign the file).

    Do you have any suggestions for what I could do here?

    Thanks again for posting this files in the first place.

    Simon

    Comment by Simon — January 30, 2008 @ 12:56 pm

  7. Hi s.Witte,

    I need to implement the multiple file upload in JSP. Is it possible? I am new to flash and have no much idea of how to implement.

    Do you have any code snippet (a non-Applet) solution, where I can select multiple files and upload them at once.

    Any help will be appreciated. Please mail me to sakvk@yahoo.com.

    Regards,
    Sarika

    Comment by sarika — February 20, 2008 @ 9:06 am

  8. Hi,
    Is there anyway to display the image once uploaded?
    Andy

    Comment by Andy — February 23, 2008 @ 12:36 pm

  9. Hello,

    I have tested the sript on Firefox/2.0.0.12 and thats on a vista machine the script don’t really work if you browse multiple times. Not every file is uploaded. It’s a pitty because its a very nice script.

    If you want that i test more versions please email me.

    Greetings (groetjes),
    Ernesto

    Comment by Ernestomodena — March 7, 2008 @ 12:06 pm

  10. Hey, that’s no error message?

    And if the upload directory is wrong?

    Can I send a form with the file to make an insert in the BD?

    Tks..

    Comment by Wagner — March 24, 2008 @ 9:03 pm

  11. Multiple Upload Solution; Using Javascript, Flash and PHP…

    A problem i often encouter is that people, often customers, would like to upload multiple files all together, instead of, what you often see, one file at the time. Of course a very simple solution is to put multiple HTML upload fields on a page, but ob…

    Trackback by Bookmarks.WittySparks.com — May 27, 2008 @ 4:38 pm

Leave a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word