# Flash/PHP: Why does this work in Flash preview/projector, but not in a browser?

**URL:** <https://forum.kirupa.com/t/flash-php-why-does-this-work-in-flash-preview-projector-but-not-in-a-browser/271502>\
**Category:** programming\
**Created:** [September 23, 2008, 8:21pm UTC](https://forum.kirupa.com/t/flash-php-why-does-this-work-in-flash-preview-projector-but-not-in-a-browser/271502 "2008-09-23T20:21:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpann](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tpann](https://forum.kirupa.com/u/tpann)\
**Post date:** [September 23, 2008, 8:21pm UTC](https://forum.kirupa.com/t/flash-php-why-does-this-work-in-flash-preview-projector-but-not-in-a-browser/271502/1 "2008-09-23T20:21:42Z")

</div>

[also posted this on Actionscript 3 forum but I’m having trouble getting a response]

I’m using the following Actionscript 3 code to generate a new text file (myFile.txt) with some text in it:

Actionscript:

```php
var req:URLRequest = new URLRequest("http://localhost/workDir/save.php");
req.method = URLRequestMethod.POST;
var postVars:URLVariables = new URLVariables();
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;

submitBtn.addEventListener(MouseEvent.CLICK, submitData);
function submitData(event:MouseEvent):void {
	postVars.fName = "myFile";
	postVars.fFormat = ".txt";
	postVars.fText = "Type some text here.";
	req.data = postVars;
	loader.addEventListener(Event.COMPLETE, loaderFinished);
	loader.load(req);
}
function loaderFinished(evt:Event):void {
	trace("Submit complete, data: " + loader.data);
	output_txt.text = "Submit complete";
}

```

Here’s save.php:

```php
<?php

	$fileName = $_POST['fName'].$_POST['fFormat'];
	$fileText = $_POST['fText'];
	
	$file = fopen($fileName, "a+");

	fwrite($file, $fileText);
	
	fclose($file);
	
	echo "$resu1=Created ".$fileName;
	echo "$resu2=Created ".$fileText;
?>

```

When I run the standalone swf, and when I publish as a projector (.exe), everything works fine. When I publish and open the HTML with the swf embedded, it doesn’t work – no file, no “Output complete” in the output\_txt field.

What am I missing?
