# Create a File using PHP/AS

**URL:** https://forum.kirupa.com/t/create-a-file-using-php-as/193704
**Category:** flash
**Created:** [July 15, 2006, 3:42pm UTC](https://forum.kirupa.com/t/create-a-file-using-php-as/193704 "2006-07-15T15:42:49Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jbailey](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jbailey/32/2380_2.png) [@jbailey](https://forum.kirupa.com/u/jbailey)
#### Post date: [July 15, 2006, 3:42pm UTC](https://forum.kirupa.com/t/create-a-file-using-php-as/193704/1 "2006-07-15T15:42:49Z")

</div>

[LEFT] **Goal** Button in Flash along with an input field passes the input field text to PHP and creates a new file on the server.

**Problem**  
The problem right now is just with the PHP. It won’t create a new file when asked to pass variables. It will only work when hard coded. This means it works when I type: [www.url.com/createfile.php](http://www.url.com/createfile.php) and the php contains the file name hard coded (ie $file = “new.xml”). It won’t work if I remove the hard code and type [www.url.com/createfile.php?file=new.xml](http://www.url.com/createfile.php?file=new.xml).

**Attempts**  
I’ve tried sever methods. Below is the code I’m using. As you can see I’m the methods I’ve tried are contained in there too, but marked out.

```auto

<?php
$_GET['File'];
//header("Content-Type: text/plain");
header("Content-Disposition: inline; filename=$file");
//$ourFileName = "testFile.xml";
//$file = $ourFileName;
$ourFileHandle = fopen($file, 'w') or die("can't open file");
//$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
/*
$data = "This is a new file entry!
";   
if (!$file_handle = fopen($file,"w")) { echo "Cannot open file"; }  
if (!fwrite($file_handle, $data)) { echo "Cannot write to file"; }  
echo "You have successfully written data to $file";   
fclose($file_handle);  
*/
?>

```

In AS I’m just using the getURL method. However, the problem is with the php, because right now I’m ONLY testing in php not using Flash yet. Like I described above  
[/LEFT]
