This may have been covered already, if so my apologies – I’m not sure what to search on.
I have a FLA file designed to create a text file and send the values of some variables to that file via a PHP file. It works great when I do a Test Movie (CTRL+Enter) but when I publish the movie and try it from a browser, nothing happens.
Actually, the first time I tried it in IE I got that familiar “Adobe player has stopped a potentially unsafe operation” dialog that provides a link go change my Flash Player Global Security settings – but my settings are already set to “Always Allow.”
Also, if it makes a difference, I have set Publish Settings/Flash tab/Local playback security: to “Access network only.”
I’m a complete newbie to this PHP stuff and to security etc., and I assume this has to do with security?
I installed WAMPSERVER 2.0 and have it running. Here’s the meat and potatoes of my FLA file, which gets the values for the variables via input fields:
var fileFormat:String = ".txt";
var req:URLRequest = new URLRequest("http://localhost/sephiroth/save2.php");
req.method = URLRequestMethod.POST;
var postVars:URLVariables = new URLVariables();
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
postVars.fName = "_" + firstNameField.text + " " + lastNameField.text;
postVars.fFormat = fileFormat;
postVars.fText = lastNameField.text + " "
+ firstNameField.text + " score = "
+ Number(scoreField.text) + ": "
+ passFail;
req.data = postVars;
loader.addEventListener(Event.COMPLETE, done);
loader.load(req);
function done(event:Event):void {
//some code here...
}
That’s an abbreviated code block, BTW – if it looks like something’s missing, that’s because I left some stuff out for all y’all’s sake.
Here’s save2.php:
<?php
$fileName = $_POST['fName'].$_POST['fFormat'];
$fileText = $_POST['fText'];
$file = fopen($fileName, "a+");
fwrite($file, $fileText);
fclose($file);
?>
Again, everything works exactly as I want it to when I do a CTRL+Enter but not when published in a browser.
Would appreciate any help – I assume this is probably a no-brainer for lots of folks out there.