Hi there
I have some fairly straightforward AS3 code that uploads a file to my server:
Flash:
function boothsEdit1BannerUploadClick(e:MouseEvent):void
{
boothsEdit1File = new FileReference();
var imgFileTypes:FileFilter = new FileFilter("Imgs (*.jpg, *.png)", "*.jpg;*.png;");
boothsEdit1File.browse([imgFileTypes]);
boothsEdit1File.addEventListener(Event.SELECT, boothsEdit1BannerUploadSelectFile);
}
function boothsEdit1BannerUploadSelectFile(event:Event):void
{
boothsEdit1DisableUI();
boothsEdit1Status.text = "Banner uploading please wait...";
var requestUpload:URLRequest = new URLRequest(boothsEdit1UploadScript);
boothsEdit1File.upload(requestUpload);
boothsEdit1File.addEventListener(Event.COMPLETE, boothsEdit1BannerFileLoaded);
}
function boothsEdit1BannerFileLoaded(event:Event):void
{
boothsEdit1EnableUI();
boothsEdit1Status.text = "Banner successfully uploaded";
}
And the PHP upload script:
if(!is_dir("./files")) mkdir("./files", 0755);
move_uploaded_file($_FILES['Filedata']['tmp_name'], "./files"."/".$_FILES['Filedata']['name']);
chmod("./files"."/".$_FILES['Filedata']['name'], 0777);
This all works great but my problem is, many users will be uploading their banners to this system and so I don’t want them all in the same directory (/files) as the chances are they will be called banner.jpg etc.
In the Flash code I am then saving the url of the uploaded banner as “domain.com/files/filename” as this needs to be stored.
So I would ideally like to use a unique ID for the directory. E.g. if I am using the system with my user ID of 156…it could upload my banner in to a folder called files156.
The problem I have is, how can I pass that ID number to the PHP upload script? How can I add a variable called ‘id’ to my Flash code so that my PHP code can receive it using POST?
Any ideas appreciated.
Thanks
Gemma