Reputation:
Normally when I send information to PHP scripts via URLLoader, I have the PHP return various success codes so I can have my Flash files respond according to whatever success code the PHP returns (0 is a failure, 1 a success, 2 is some other error code, etc.).
Now I'm trying to submit a form with a bunch of data in it (name, email, birthday, etc.) as well as upload a file. I'm using fileReference to upload the file and send the additional variables along with the upload request. The information is making it to my PHP file fine. However, I can't find any way to get information BACK from the PHP file. That is to say, I want the PHP to echo "success=1" if the file is successfully loaded, "success=2" if there was an error inserting the data into the MySQL database, etc., but currently I can't figure out how to get info from the PHP. Normally I could just look at _myURLLoader.data but in this instance I need to reference _fileReference.data which is actually the bitmap data of the file.
Anybody have any ideas?
Thanks!
--eric
Upvotes: 1
Views: 1403
Reputation: 1660
A totally different approach is to install Fiddler on your system. If you're dealing with https traffic you can use it to decrypt all transmissions via your nic. This won't help your flex app deal with responses, but you'll be able to observe the server feedback during debugging/development.
Upvotes: 0
Reputation: 3794
Since Flash Player 9.0.28.0 (I think) you can use the uploadCompleteData event. Before that, you had to use the technique described by Bill H ^^
Upvotes: 1
Reputation: 15
You can use the http status to tell flash what happens when you upload a file.
On the php side, to tell flash the file was not received I do the following:
if(!isset($_FILES['Filedata']['name']))
{
header("HTTP/1.x 500");
print "RESULTS=FAIL";
exit();
}
If the file is larger than what I want:
if(!isset($_FILES['Filedata']['size']) > $maximumuploadsize)
{
header("HTTP/1.x 406");
print "RESULTS=FAIL";
exit();
}
Etc.
Then on the flash side I'll setup an .onHTTPError listener such as:
photo.onHTTPError = function(file:FileReference, httpError:Number)
{
switch (httpError)
{
case 500:
// Handle missing file
break;
case 406:
// Handle file too large
break;
}
}
Bill H
Upvotes: 2
Reputation: 9300
I would check a couple things.
First, what is your error_reporting set to? You may have an error in your PHP and nothing is getting output because execution stopped.
Also, try using the error_log() function and check the logs for what was output.
Upvotes: 0