PHP Flash File Upload - Variable Sending?

Hi All,

I’ve recently managed to create a file upload function in flash using the FileReference method. Right now a user can upload an image to a set directory on my server and that works fine, however i would like to have a user be able to upload their images into their own unique folder.

The way i would imagine doin this is by sending a variable to the same php script that processes the image and adjust the path accordingly in the PHP script. However is it possible to send variables to a PHP script through using the FileReference class?

Here is my PHP code. I noticed that data is captured from the flash file somehow with the $_FILE attribute.

<?php
//CHECK DIRECTORY IS AVAILABLE, IF NOT CREATE
if(!is_dir("./userimages")) mkdir("./userimages", 0755); 
//MOVE UPLAODED FILE TO DIRECTORY
move_uploaded_file($_FILES['Filedata']['tmp_name'], "./userimages/".$_FILES['Filedata']['name']);
chmod("./userimages/".$_FILES['Filedata']['name'], 0777);
?>

Is there anyway to add custom information using the FileReference class that can be used by the php script?

Here is my AS code, which uploads an image, and also downloads it for display back to the user, adapted from a tutorial at: http://www.flash-db.com/Tutorials/upload/


//SET PERMISSION FOR USER DOMAIN
System.security.allowDomain("http://localhost/");
//IMPORT FILEREFERENCE CLASS
import flash.net.FileReference;
// LISTEN FOR FILEREFERENCE EVENTS
var listener:Object = new Object();
//WHEN FILE IS SELECTED
listener.onSelect = function(selectedFile:FileReference):Void  {
    //CLEAR STATUS AREA AND DETAILS
    uploadstatus_txt.text = details.text="";
    //SHOW ATTEMPT
    uploadstatus_txt.text += "Attempting to upload "+selectedFile.name+"
";
    //UPLOAD THE FILE
    selectedFile.upload("http://www.sole-space.com/upload.php");
};
// WHILE UPLOADING
listener.onOpen = function(selectedFile:FileReference):Void  {
    uploadstatus_txt.text += "Uploading "+selectedFile.name+"
";
};
//CHECK AND DISPLAY ERRORS
listener.onHTTPError = function(file:FileReference, httpError:Number):Void  {
    imagePane.contentPath = "error";
    imagePane.content.errorMSG.text = "HTTPError number: "+httpError+"
File: "+file.name;
};
listener.onIOError = function(file:FileReference):Void  {
    imagePane.contentPath = "error";
    imagePane.content.errorMSG.text = "IOError: "+file.name;
};
listener.onSecurityError = function(file:FileReference, errorString:String):Void  {
    imagePane.contentPath = "error";
    imagePane.content.errorMSG.text = "SecurityError: "+SecurityError+"
File: "+file.name;
};
//ON UPLOAD COMPLETE
listener.onComplete = function(selectedFile:FileReference):Void  {
    //ATTEMPT IMAGE DOWNLOAD
    uploadstatus_txt.text += "Upload finished.
Now downloading "+selectedFile.name+" to player
";
    //SHOW FILE DETAILS
    details.text = "";
    for (i in selectedFile) {
        details.text += "<b>"+i+":</b> "+selectedFile*+"
";
    }
    // DOWNLOAD IMAGE
    downloadImage(selectedFile.name);
};
var imageFile:FileReference = new FileReference();
imageFile.addListener(listener);
choose_btn.onRelease = uploadImage;
imagePane.addEventListener("complete", imageDownloaded);
// OPEN FILE BROWSER
function uploadImage(event:Object):Void {
    imageFile.browse([{description:"Image Files", extension:"*.jpg;*.gif;*.png"}]);
}
// SHOW IF DOWNLOAD ERROR
function imageDownloaded(event:Object):Void {
    if (event.total == -1) {
        imagePane.contentPath = "error";
    }
}
// SHOW DOWNLOADED IMAGE
function downloadImage(file:Object):Void {
    imagePane.contentPath = "http://www.sole-space.com/userimages/"+file;
}

This is my first experience with the file reference class, so apologies if this is a dumb question. Many thanks in advance!