# Call to create .txt file through .php script

**URL:** <https://forum.kirupa.com/t/call-to-create-txt-file-through-php-script/300056>\
**Category:** Uncategorized\
**Created:** [November 15, 2009, 5:28pm UTC](https://forum.kirupa.com/t/call-to-create-txt-file-through-php-script/300056 "2009-11-15T17:28:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mayoarm11](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@mayoarm11](https://forum.kirupa.com/u/mayoarm11)\
**Post date:** [November 15, 2009, 5:28pm UTC](https://forum.kirupa.com/t/call-to-create-txt-file-through-php-script/300056/1 "2009-11-15T17:28:31Z")

</div>

hi. I’ve tried running a .swf file on my website, which is supposed to call upon a .php file to create a .txt file. The .swf also specifies the name of the file, and its content. Below is what I currently tried, and expectedly, it failed 🙂 Please tell me what I’m doing wrong! Thanks in advance.

**in the .swf file (AS2):**

```auto
var sendData = new LoadVars();
sendData.name = "myfile";
sendData.body = "hello this is text lol";
sendData.sendAndLoad("http://www.kotr-tao.com/createText.php",sendData,"GET");
sendData.onLoad = function(suc) {
    if (suc == true) {
        txt.text = "Sent!"; //txt is a dynamic textbox in the first frame
    } else {
        txt.text = "Failed!";
    }
};

```

\*\*in the .php file (createText.php):  
\*\*

```auto
<?php

$name = $_GET['name'];
$body = $_GET['body'];

$cname = trim($name);

if (!empty($cname))
{
    $theFile = $name;
    $fp = fopen($theFile, 'w');
    fwrite($fp, $body);
    fclose($fp);
}
?>

```
