# Write data to file

**URL:** https://forum.kirupa.com/t/write-data-to-file/262394
**Category:** flash
**Created:** [June 5, 2008, 4:24pm UTC](https://forum.kirupa.com/t/write-data-to-file/262394 "2008-06-05T16:24:01Z")
**Posts on this page:** 4
**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: [June 5, 2008, 4:24pm UTC](https://forum.kirupa.com/t/write-data-to-file/262394/1 "2008-06-05T16:24:01Z")

</div>

I know this has been asked but I’m not finding a direct, simple answer to my question in the archives.

Very simply: In AS3, can I write data to a file? I have composed a quiz and I need to get a user’s result out of the .swf and into a file.

If this can’t be done, why not?

If so, what’s the simplest way?

I know there is a way to do it using PHP, but I have no PHP experience, so if that’s the answer, I would appreciate a link or a file that illustrates.

Thanks!

---

<div class="post-metadata">

### Author: ![unformatt](https://avatars.discourse-cdn.com/v4/letter/u/58956e/32.png) [@unformatt](https://forum.kirupa.com/u/unformatt)
#### Post date: [June 5, 2008, 5:39pm UTC](https://forum.kirupa.com/t/write-data-to-file/262394/2 "2008-06-05T17:39:40Z")

</div>

Whatever data you have, you need to send it to a webserver first - you can’t directly save it as a local file. There is a [blog post here](http://tush.wordpress.com/2007/07/20/actionscript-3-using-urlloader-to-send-and-load-server-variables/) about sending data in AS3

---

<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: [June 5, 2008, 8:15pm UTC](https://forum.kirupa.com/t/write-data-to-file/262394/3 "2008-06-05T20:15:20Z")

</div>

Thanks for that unformatt!

---

<div class="post-metadata">

### Author: ![Alex\_Lexcuk](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Alex\_Lexcuk](https://forum.kirupa.com/u/Alex_Lexcuk)
#### Post date: [June 5, 2008, 9:21pm UTC](https://forum.kirupa.com/t/write-data-to-file/262394/4 "2008-06-05T21:21:34Z")

</div>

[http://dnadillo.dn.ua/fla/php/php.swf](http://dnadillo.dn.ua/fla/php/php.swf)  
[http://dnadillo.dn.ua/fla/php/application.txt](http://dnadillo.dn.ua/fla/php/application.txt)

[http://dnadillo.dn.ua/fla/php/php-flash-write.zip](http://dnadillo.dn.ua/fla/php/php-flash-write.zip)  
[http://dnadillo.dn.ua/fla/php/php-flash-write.txt](http://dnadillo.dn.ua/fla/php/php-flash-write.txt)

```auto

<?php

$result_name=strip_tags($_GET['sessionId']);//chacker killer
$result_score=strip_tags($_GET['userLabel']);//chacker killer

//&#1086;&#1073;&#1088;&#1072;&#1073;&#1072;&#1090;&#1099;&#1074;&#1072;&#1077;&#1084; &#1087;&#1086;&#1083;&#1091;&#1095;&#1077;&#1085;&#1085;&#1099;&#1077; &#1076;&#1072;&#1085;&#1085;&#1099;&#1077; &#1080; &#1089;&#1086;&#1079;&#1076;&#1072;&#1077;&#1084; &#1084;&#1072;&#1089;&#1089;&#1080;&#1074;
$split_data=$result_name.'&'.$result_score.'&'.$result_time."
";
echo $result;

if (filesize("application.txt")<300)
 {
  $fh=fopen("application.txt","a+");//add on finish file
  }
else 
 {
  $fh=fopen("application.txt","w");
  }

fwrite($fh,$split_data);//write file
echo $buff; //
fclose($fh);//close file

?>

```
