Flash File Uploader (Updated)
Due to popular demand (and numerous positive remarks from Donline viewers) Mike reformatted the PHP files associated with the Flash File Uploader to increase security, support auto-generated thumbnail caching and enable preview mode (prior to upload).
Flash File Uploader
Click the above link to go to the original Flash File Uploader posting on Donline with new source files.
Click the above link to go to the original Flash File Uploader posting on Donline with new source files.

July 4th, 2007 at 2:49 am
I could really use your help with a project that I think you’ll really like. I’ve been seeking someone who works with flash, php, and mySQL, but it’s tough to find someone that seems to have your combination of skills. Is it possible that you could contact me in reference to this.
September 12th, 2007 at 3:35 pm
Thank you, Don!
October 5th, 2007 at 4:11 pm
Hi Don,
I really need your help in terms of expanding this script. Is there some way to contact you? I am more than willing to pay for your time. thanks!
October 22nd, 2007 at 7:46 pm
Great job. How can I use javascript to ask the flash control to upload a file? thanks!
October 22nd, 2007 at 8:38 pm
Andrew, I sent you a note offline. Edwin, am I correct in assuming that you’d like an HTML File field with javascript passing the file location to the Flash File Uploader?
November 9th, 2007 at 9:40 am
Hallo, I agree with them below -
“I love Flash’s upload. It’s so much better than the extremely crap HTML upload.”
I only want (or wonder) if it possibble to higher the upload limit from NOW about 12 mb - to let say atleast 250 mb - to the server - blocket.be - I offer FREE trade ad world wide - so I would be pleased if you can help me out - so far what I KNOW the fastes uploder on the world net - I try about 50+ and your Flash’s upload works great; to se it in action please visit;: http://www.blocket.be/flashupload/ …
also one off the easy to install…
Great work and many thank’s - it’s is a mysterium how people make this coded FREE TOOLS for us that not know anything!´
Ciao,
/ Roman
November 9th, 2007 at 3:11 pm
You’ll probably need to adjust the MAXs and TIMEs if you want to increase upload sizes:
max_execution_time (in seconds)
max_input_time (in seconds)
memory_limit (in mb)
post_max_size (in mb)
upload_max_filesize (in mb)
also, in the uploader HTML/PHP file, you’ll see the following SWFObject Variable:
fo.addVariable(”limit”, “100″);
This means the overall limit of the flash file uploader is 100mb. You can increase it as necessary, but it should be the same as the server variable.
November 9th, 2007 at 3:48 pm
I probably should have mentioned that those directives are to be updated in php.ini by your host or network administrator.
December 19th, 2007 at 11:13 am
Hi Don,
Thanks for your work !
I have only one problem… It’s with $_SESSION and Flash…
I would like to upload files in the directory of the user who is uploading, and this directory is like $_SESSION[’dir’] = “/files/”.$name_of_member;
The problem is that Flash doesn’t like $_SESSION, it skip it.
So I try to do that :
var fo = new SWFObject(”uploader.swf?ul=100″, “flash_uploader”, “435″, “40″, 8, “#FFFFFF”, true);
fo.addParam(”allowScriptAccess”, “sameDomain”);
fo.addParam(”quality”, “high”);
fo.addParam(”scale”, “noscale”);
fo.addVariable(”to”, “upload.php?SESSID=”);
fo.addVariable(”limit”, “100″);
fo.addVariable(”types”, “video|text|pdf|image|audio”);
fo.write(”flashcontent”);
And at the beggining of upload.php :
December 19th, 2007 at 11:16 am
Code doesn’t work.. :
var fo = new SWFObject(”uploader.swf?ul=100″, “flash_uploader”, “435″, “40″, 8, “#FFFFFF”, true);
fo.addParam(”allowScriptAccess”, “sameDomain”);
fo.addParam(”quality”, “high”);
fo.addParam(”scale”, “noscale”);
fo.addVariable(”to”, “upload.php?SESSID=<?php echo $_COOKIE[’PHPSESSID’]; ?>”);
fo.addVariable(”limit”, “100″);
fo.addVariable(”types”, “video|text|pdf|image|audio”);
fo.write(”flashcontent”);
And at the beggining of upload.php :
<?php
session_id($_GET[’SESSID’]); if( !isset($_SESSION) ) session_start();
to have :
$filepath = getcwd().”/files/”.$_SESSION[’dir’];
December 19th, 2007 at 4:16 pm
Hi Guillaume, You’ll need to add an additional variable to the index.php file to pass the path to the flash, like this:
fo.addVariable(”path”, “< ?$userpath?>“);
Then, the Flash should pass the user path to the upload.php script with something like this:
item.upload(”upload.php?d=true&type=”+extension+”&name=”+escape(item.name)+”&size=”+item.size+”&ft=”+exts+”&path=”+_root.path);
And you can modify the upload.php file to know where to store your file:
move_uploaded_file($_FILES[’Filedata’][’tmp_name’], FILE_PATH . $_GET[‘path’] . “/” . _newfilename_ );
Should work like a charm. If you’re still having problems let me know and I’ll send you an address to send the files so I can take a look.
January 23rd, 2008 at 12:56 pm
I love the upload script but I need to pass a few other field in the form not just the file upload. Is this possible? Thanks
January 23rd, 2008 at 1:31 pm
Absolutely. If you modify the Flash file to include other form elements, simply pass it to the PHP script to store. If you need help, just reply and I’ll send you my email.
January 23rd, 2008 at 3:22 pm
Don,
Your help would be greatly appreciated. Thanks
February 2nd, 2008 at 3:01 pm
Hi Don, this is a very cool application you have built. I would like to change the file types to be uploaded. For example I added *.tif files to the images in the Action Script but when uploading a tif the webpage says that the file could not be uploaded. I also added my own case for compressed files:
case “package” :
var packageTypes:Object = new Object();
packageTypes.description = “Package Files (*.zip, *.sit, *.sitx, *.tar)”;
packageTypes.extension = “*.zip;*.sit;*.sitx;*.tar”;
allTypes.push(packageTypes);
exts.push(”zip”, “sit”, “sit”, “tar”);
break;
I can select the files in the open dialog box and the upload seems to go through but then returns: Error: The file could not be uploaded.
Is there any trick to adding files types? Does ity have to do with the getid3? Thanks for your help. Dan
February 2nd, 2008 at 3:40 pm
Hi again, I guess my changes worked perfectly, I just needed to update my php.ini file. :) Should have checked that first before posting my last post.
I do have another question though. My server does not have GD enabled. I could rebuild PHP but I like to you ImageMagick anyway. Is there any easy way to turn off thumbnail creation so that I don’t get an error message after uploading a jpeg? Please let me know if it is easy.
Maybe a future release could also use imagemagick.
Thanks again for your great app!
February 2nd, 2008 at 5:10 pm
To disable thumbnailing:
comment out:
/*
if(!file_exists(getcwd().”/files/”.$_GET[’cx’].”/.s/$file”) &&
array_key_exists(strtolower(substr($file,-3)),$imgtypes))
{
$srcf = getcwd().”/files/”.$_GET[’cx’].”/$file”;
$dstf = getcwd().”/files/”.$_GET[’cx’].”/.s/$file”;
$type = $imgtypes[strtolower(substr($file,-3))];
mcSaveImages(120,90,$srcf,$dstf,15,$type);
}
*/
later, in the script, $showthumbs allows them to be seen.
If you’re not using this feature,hide the switch table:
<table style=’display:none;’><tr>
<td><input type=’checkbox’ name=’thm’ id=”thm” onclick=”javascript:thumbs();” <? echo($showthumbs ? “CHECKED” : “”); ?>></td> <td colspan=”3″><p>Details?</p></td> </tr> </table>
February 2nd, 2008 at 9:42 pm
How do I change file size limit? My download did not have instructions as stated. Please help.
February 3rd, 2008 at 3:30 pm
There are two places where the file size limit is determined, for two different purposes. Update the Flash Variable in the embedding page to limit uploaded files beyond what PHP is limiting.
example:
// Limit to 100M
fo.addVariable(”limit”, “100?);
The second place is in your PHP settings on the server. If you want to upload large files, and have set your FlashVar to the above, and notice that files are still timing out, it’s probably because PHP or Apache are limiting the size of files that can be uploaded.
February 3rd, 2008 at 3:31 pm
There are two places where the file size limit is determined, for two different purposes. Update the Flash Variable in the embedding page to limit uploaded files beyond what PHP is limiting.
example:
// Limit to 100M
fo.addVariable(”limit”, “100″);
The second place is in your PHP settings on the server. If you want to upload large files, and have set your FlashVar to the above, and notice that files are still timing out, it’s probably because PHP or Apache are limiting the size of files that can be uploaded.
February 7th, 2008 at 3:04 pm
People have asked me a number of times about adding compressed packages to the Flash File Uploader. It’s quite simple on the Flash side, but you’ll need to add logic for extracting and parsing the package on the server (using PHP). Here’s how you update the Flash:
case “package” :
var pkgTypes:Object = new Object();
pkgTypes.description = “Package Files (*.gz, *.rar, *.sit, *.tar, *.zip)”;
pkgTypes.extension = “*.gz;*.rar;*.sit;*.tar;*.zip”;
allTypes.push(pkgTypes);
exts.push(”gz”,”rar”,”sit”,”tar”,”zip”);
break;
You’ll also want to update the embedded page to include packages as part of the allowed file types:
fo.addVariable(”types”, “video|text|pdf|image|audio|package”);
February 15th, 2008 at 1:12 pm
Thanks Don, your uploader is the best of all flash uploaders that I tried. This one is just great. I am really glad for this one. It helped a lot.
Keep doing great job, i love you ;D
February 15th, 2008 at 2:57 pm
Thanks, David. I love you too.
March 30th, 2008 at 10:09 pm
I can not find the embedding file. I am a flash novice, but am great at image maps and web graphics. Can you help me a little further on adding zip files and the uploader limits? Where do I find the embedding file and how to I add the case, in the getid3 file? By the way, your uploader is the best by far out there!
March 31st, 2008 at 12:09 pm
Sorry, Jennifer. I should’ve been more clear. There are a ton of words we used to use freely in the design world that have become muddled with homonymns. The embedded page is the index.php page where the flash is embedded. Though it’s not really embedded because I recommend swfobject over <embed> tags. And if I say “index” page, people assume the “index” page is the upload.php because that is the one that indexes.
Anyway, you can change the flash variables in the index.php page. scroll up and read where it says:
<fo.addparam … >
April 7th, 2008 at 6:50 am
Hey Hey Don,
Great file uploader.
I am trying to use the “to” parameter as described:
fo.addVariable(”to”, “/submit”);
but it seems like the upload.php is still hardcoded in the SWF.
I do not have Flash, so I can’t really edit the FLA.
April 14th, 2008 at 1:54 pm
Hey Don,
I am having a problem uploading video and audio files. I changed the size limit on php.ini and increased it in the php file. I keep getting this error…
Error:
The file could not be uploaded.
FILE: 6.mp3
TYPE: .mp3
SIZE: 6185112
ALLOWED: yes
I have it selected as a file type in my code. Can you help me please? thanks
http://thefutureisus.com/flashupload/index.php
April 14th, 2008 at 3:09 pm
Thanks Don! This is exactly what I was looking for… a slick light weight file upload progress bar that bypassed the browser speed limit without using java and without tons of extra junk I don\’t need that\’s easily integrated into existing layouts.
April 25th, 2008 at 10:17 am
Hi there,
Thank you again for your help.
I am still having trouble adding the zip option to the uploader. I changed the flash code and index page, but have had no luck.
Thank you again for making such a great uploader!
April 27th, 2008 at 3:39 pm
Alon, Send me your email address and I’ll send you a modified Flash Uploader FLA with your submit script hardcoded. Otherwise, you’ll need to find someone with flash to work on it with you.
Youngfonz, I tried your script and everything seemed to work fine for me.
Jonathan, glad you like it!
Jennifer, send me an email and we’ll figure it out together.
April 27th, 2008 at 8:19 pm
Don
this is the best script/flash file i have fond anywhere.. and i thiank you for your kindness in sharing.
i have one question that i hope you can help with
being a complete novice in scripting, i wouldnt know where to start.
im looking to have this form on a central site - and upload it to a defined/dynamic set of folders. im basically going to be creating a cheezy client base where people can log in and view files we have uploaded to our server.
but i want to be able to create some of these folders on the fly by inputting the name and have the file ploaded tothe new directory..
am i making sence? any ideas?
April 28th, 2008 at 9:15 am
Hi Reverend, I think the solution is the same as what Alon (above) needs…which would be to not have a hard-coded output directory. Where Alon should/could probably have the directory name passed through FlashVars, you’d probably need an additional field in the uploader where a user could enter the directory name. I’d caution against doing this, naturally, because it opens up issues with directory name validation, overwriting, etc.
Perhaps I can quickly put together a Flash File Uploader where the directory is pulled from FlashVars and this could help the two of you. Alon, who doesn’t have flash, can modify the save location. And Reverend, you can use PHP to dynamically change that FlashVars to whatever you want.
Let me know…
April 28th, 2008 at 11:52 am
Actually…I took the liberty of updating the permalink with new source files to accomplish this. Take a look at this article:
http://don.citarella.net/index.php/2008/04/28/flash-file-uploader-v30-custom-upload-directories/
April 29th, 2008 at 5:19 pm
ahhh
i get it.
i guess i was looking for a dynamic input where on www.mydomain.com/upload/ would be another text box where I could type in my own…
i assume this could be done with a bit more of coding - to automatically generate the string?
April 29th, 2008 at 5:21 pm
even to take it one further - to have the directory list be put into a pulldown - with the option to create new - and name it accordingly…
similar to the way myspace handles photo albums…
i assume that gets into database stuff?
i never knew how green i was.. hehe
May 1st, 2008 at 12:57 pm
Sure. As it is now, the PHP grabs the GET string or uses the default and passes it the Flash, which, in turn, returns it to the upload.php script. You could skip the first pass by adding an input text box in the uploader FLA that passes that variable directly to the upload.php script. Make sure, if you do this, though, you add form validation to ensure their directory name doesn’t have slashes or weird characters.
May 1st, 2008 at 12:59 pm
Well, you wouldn’t really need a database, Reverend. You could have the PHP just pass the list of directories as a SWFObject Flash Variable and the Flash could create the dropdown elements from the FlashVar array with the “Add New” option automatically appended to the bottom. Adding a database would probably be more hassle than it’s worth as you’d need to update the DB each time you wanted to add a new directory. BTW, I wouldn’t say you’re “green”, as you know all the theory behind the code…and that’s equally important to knowing the code itself. Good luck.
May 2nd, 2008 at 2:16 am
looks like i have some work ahead of me!
as soon as i get my head out from my 9-5 im going to see what i can come up with. if i get anything of substance.. ill be sure to forward it to you - and you can post it
ill keep chek in to see whats new as well
thanks again for your help
August 5th, 2008 at 8:43 am
Hello!
I was wondering if you did any special server configuration, so that the 404 error on Mac os x does not apperar. When I install the uploader, it always returns a 404 Error when the upload has finished. But when I try it on your site era404 it works perfect. Did you tune anything there. Do I have to configure something special on the server? (gentoo)
Thanks for your sugestions.
Guido
August 6th, 2008 at 12:31 pm
Hi Guido, The uploader will produce 404 errors if the file was restricted after it was copied to the server. Sometimes this happens if the file size is greater than the max filesize, memory or post max settings of the server. The uploader will attempt to upload the file to a temporary folder and the PHP will then copy the file over to your desired folder (see information about custom directories). If PHP recognizes that the file is too large, or the server settings are too low/small, the file won’t be able to be copied to the custom directory. Check your php.ini file or try uploading an extremely small file to see if this is the issue you’re experiencing. It may also have something to do with the permissions PHP needs to copy the file to the new location. If your uploaded file is not being moved (due to size or permission constraints), you’ll get a 404. Hope this helps. -Don