Advertisement
Advertisement
| 08.21.2008 at 09:55PM PDT, ID: 23669305 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: |
/**
*
* AS snippet
*
*/
// Create a file reference
var file:FileReference = new FileReference();
// Get the session ID from the cookie
var res:String
= ExternalInterface.call('function(){return document.cookie;}');
var sidStr:String = res.substr(10,res.length);
// Create a new URL Request
var req:URLRequest = new URLRequest();
req.url = "http://mysite.com/php/session.php";
req.method = URLRequestMethod.POST;
var reqvars:URLVariables = new URLVariables();
reqvars.sid = sidStr;
// Upload File (myFileFieldName is the name of the file in $_FILES var)
file.upload( req, myFileFieldName );
/**
*
* PHP snippet
*
*/
// Get the session ID and start the session
session_id( $_POST['sid'] );
session_start();
// Return the info to the Flash App as XML for parsing
header("Content-type: text/xml");
$xml = new DOMDocument('1.0', 'iso-8859-1');
$child = $xml->createElement("upload");
$data = $xml->createElement("data");
// Returned XML contains the correct session id
$ssid = $xml->createElement("ssid",session_id());
// But not the user information, and session is unset or
// otherwise destroyed/lost/who knows
$info = $xml->createElement("userInfo",$_SESSION['userInfo']);
$data->appendChild( $info );
$data->appendChild( $ssid );
$child->appendChild($data);
$xml->appendChild( $child );
echo $xml->saveXML();
exit();
|