I have a very simple PHP script that creates a new file on my server using a random number for the file name (e.g., 412561.txt). When I load the script directly from a browser, it works. But when I load the script from a very simple Flash (AS3) script, it does not work (i.e., doesn't create a file). The Flash script and PHP script are both in the same directory. Permissions on the directory and its content are 755. Temporarily setting those permissions to 777 does not solve the problem (i.e., PHP still doesn't create file when called via Flash).
Here is my phpinfo.
Here is the PHP file.
The contents of the PHP file are:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$RandomNumber = rand(1,1000000);
$filename = "$RandomNumber" . ".txt";
$filecontent = "This is the content of the file.";
if(file_exists($filename))
{$myTextFileHandler = fopen($filename,"r+"); }
else
{$myTextFileHandler = fopen($filename,"w"); }
if($myTextFileHandler)
{$writeInTxtFile = @fwrite($myTextFileHandler,"$filecontent");}
fclose($myTextFileHandler);
?>
Here is the html container for the Flash script. The Flash script features a single button which calls the PHP script when pressed. In case it helps, here is the raw Flash file itself. The code of the Flash script is as follows:
stop();
var varLoader:URLLoader = new URLLoader;
var varURL:URLRequest = new URLRequest("http://www.jasonfinley.com/research/testing/TestingSaveData.php");
btnSave.addEventListener(MouseEvent.CLICK,fxnSave);
function fxnSave(event:MouseEvent):void{
btnSave.enabled=false;
varLoader.load(varURL);
}
Directory listing is enabled at the parent directory here, so you can see there when a new text file is created or not. (Um, if this is a security disaster, please let me know!)
Can anyone please help me understand why this isn't working and how I can fix it? Thank you
~jason