[thelist] Flash uploading problem

Dan Sheetz dan at goodfoodpro.com
Fri Aug 31 12:48:41 CDT 2007

Hello all,

I'm having a voodoo-like problem with uploading files through flash.   
I have a swf that's part of a custom CMS tool that allows users to  
upload a logo and header image to configure their page.  The system  
works perfectly on one of my servers (hosted on Mosso.com), but  
breaks inexplicably when placed on a LAMP server hosted by  

The mosso server runs PHP 4.4.7.  The softlayer server runs PHP  
4.3.9... just in case that could have anything to do with this.

The system uses the following little PHP script to receive the  
uploaded file:


//create the directory if doesn't exist (should have write permissons)
if(!is_dir("./uploads")) mkdir("./uploads", 0755);

//move the uploaded file
move_uploaded_file($_FILES['Filedata']['tmp_name'], "./uploads/". 
chmod("./uploads/".$_FILES['Filedata']['name'], 0777);


and here's the actionscript for the file uploader widget:


// allow this domain
import flash.net.FileReference;

// the listener object listens for FileReference events.
var listener:Object = new Object();

// when the user selects a file, the onSelect() method is called, and
// passed a reference to the FileReference object.
listener.onSelect = function(selectedFile:FileReference):Void {
   // flash is attempting to upload the image.
   statusArea.text = "Attempting to upload " + selectedFile.name + "\n";
   // upload the file to the PHP script on the server.

// the file is starting to upload.
listener.onOpen = function(selectedFile:FileReference):Void {
   statusArea.text = "Uploading " + selectedFile.name + "\n";

listener.onProgress = function(selectedFile:FileReference):Void {
   statusArea.text = "Uploading " + selectedFile.name + "\n";

// possible file upload errors
listener.onHTTPError = function(file:FileReference,  
httpError:Number):Void {
	statusArea.text = "HTTPError number: "+httpError +"\nFile: "+  

listener.onIOError = function(file:FileReference):Void {
	statusArea.text = "IOError: "+ file.name;

listener.onSecurityError = function(file:FileReference,  
errorString:String):Void {
	statusArea.text = "SecurityError: "+SecurityError+"\nFile: "+  

// the file has uploaded
listener.onComplete = function(selectedFile:FileReference):Void {
   // notify the user that Flash is starting to download the image.
   statusArea.text = "Upload finished.\nNow downloading " +  
   // show file details
   details.text = ""
   for(i in selectedFile) details.text +="<b>"+i+":</b> "+selectedFile 
   // call the custom downloadImage() function.

var imageFile:FileReference = new FileReference();


The file uploads successfully on both servers, but on the SoftLayer  
server, the listener.onComplete method is not called after the file  
is uploaded.

Could this be a php.ini problem?  An apache problem?  I am at a  
loss.  Any kind of direction or similar experience from others who  
have used flash for file uploading would be much appreciated.


Dan Sheetz
Good Food Productions

More information about the thelist mailing list