;

PDA

Click to See Complete Forum and Search --> : Sending variable to PHP along with FileReference


metallicamatt
10-12-2006, 02:53 AM
I reviewed and attempted both of these posts (http://board.flashkit.com/board/showthread.php?t=699895&highlight=send+variable+upload) for a good portion of the day, but can't seem to achieve this:

I have an app. where people can create their own brochure by replacing fields with their own text & uploading their own images to replace the existing images. Since I have multiple (7) FileRef. objects in one form (with a button above each image to be replaced), I need to send a variable with the images that get uploaded. I want to change the name of the uploaded file so that when the file is moved to the correct folder on the server, I'll know which image button was used. For ex. - rename the file "DSC1035.JPG" or "DSC1036.JPG" to something like "Image1-DSC1035.JPG", "Image2-DSC1036.JPG" etc. I also wouldn't mind adding the date and time of the upload, like this "DateTime-Image1-DSC1035.JPG" but would settle for just the name change.

The code I have working for the upload in ActionScript creates new objects for each button (listener1 for selectedFile1, listener2 for selectedFile2, etc):

var listener1:Object = new Object()
listener1.onSelect = function(selectedFile1:FileReference):Void {
_parent._parent.statusArea.text += "Attempting to upload " + selectedFile1.name + "\n";
selectedFile1.upload("http://www.megahometours.com/upload.php/*maybe add*/?imageNumber="+Image1/*here*/");
loader._x = 347;
loader._y = 215;
loader._visible = true;
loader.uploadcircle._visible = true;
loader.downloadcircle._visible = false;
loader.loadingTxt.text = "Uploading...";
}
listener1.onOpen = function(selectedFile1:FileReference):Void {
_parent._parent.statusArea.text += "Opening " + selectedFile1.name + "\n";
}

etc.

And in PHP:

$MAXIMUM_FILESIZE = 1024 * 2000; // 2000KB
$MAXIMUM_FILE_COUNT = 30; // keep maximum 10 files on server
echo exif_imagetype($_FILES['Filedata']);
if ($_FILES['Filedata']['size'] <= $MAXIMUM_FILESIZE) {
move_uploaded_file($_FILES['Filedata']['tmp_name'], "./temporary/".$_FILES['Filedata']['name']/*and*/.$imageNumber/*here?*/);
$type = exif_imagetype("./temporary/".$_FILES['Filedata']['name']);
if ($type == 1 || $type == 2 || $type == 3) {
rename("./temporary/".$_FILES['Filedata']['name'], "./images/".$_FILES['Filedata']['name']);
} else {
unlink("./temporary/".$_FILES['Filedata']['name']);
}
}

etc.

Any help would be much appreciated.

Thanks,
Matt

metallicamatt
10-18-2006, 03:10 AM
I'd love it if someone would hook me up with this...

Thanks alot,
Matt

Musicman
10-18-2006, 03:23 AM
Hi,

consider starting a session from your index.php file - then the "bit to add" could be the session ID

Musicman