# AS3 File Upload

**URL:** https://forum.kirupa.com/t/as3-file-upload/233763
**Category:** flash
**Created:** [July 26, 2007, 5:43pm UTC](https://forum.kirupa.com/t/as3-file-upload/233763 "2007-07-26T17:43:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Blommestein](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@Blommestein](https://forum.kirupa.com/u/Blommestein)
#### Post date: [July 26, 2007, 5:43pm UTC](https://forum.kirupa.com/t/as3-file-upload/233763/1 "2007-07-26T17:43:33Z")

</div>

I cannot seem to get this to work.

I have everything open-source here: [http://ustudios.net/blommestein/test/](http://ustudios.net/blommestein/test/)

The actionscript:

```auto
var fileRef:FileReference = new FileReference();
var fileFil:FileFilter = new FileFilter("GIF Image", "*.gif;");
fileRef.addEventListener(Event.SELECT, selectHandler);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
try {
    var success:Boolean = fileRef.browse([fileFil]);
} catch (error:Error) {
    trace("Unable to browse for files.");
}
function selectHandler(event:Event):void {
    var request:URLRequest = new URLRequest("upload.php")
    try {
        fileRef.upload(request);
        navigateToURL(request);
    } catch (error:Error) {
        trace("Unable to upload file.");
    }
}
function completeHandler(event:Event):void {
    trace("uploaded");
}

```

The php script (upload.php):

```php
<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  echo "Type: " . $_FILES["file"]["type"] . "<br />";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }
?>

```

When running [http://ustudios.net/blommestein/test/Test.swf](http://ustudios.net/blommestein/test/Test.swf) , it should just create a temporary copy on the server, however NONE of the properties are read, as shown below:

```auto
Upload: 
Type: 
Size: 0 Kb
Stored in:

```

Can anybody tell me what is wrong, or link me to a working upload script?
