Uploading with FileReference

Hi,

Im working on a project that requires me to upload images to the server. I’m getting everything to work, however it will not upload the image. Can you take a look at my code and let me know what I’m doing wrong?

Actionscript


import flash.net.FileReference;
var file : FileReference = new FileReference();
upload_btn.enabled=false;
upload_btn.alpha = .5;

browse_btn.addEventListener(MouseEvent.CLICK,browseImages);


function browseImages(e:MouseEvent) {
        file.addEventListener(Event.SELECT, selectHandler);
        file.browse( new Array( new FileFilter( "Images (*.jpg, *.jpeg, *.gif, *.bmp)", "*.jpg;*.jpeg;*.gif;*.bmp" ) ) );
       
}

 function selectHandler(e:Event) {
                fileBox.text = file.name;
                upload_btn.enabled=true;
                upload_btn.alpha = 1;
                upload_btn.addEventListener(MouseEvent.CLICK,uploadMedia);
                myfile.text = "http://www.myaddress.com/files/" + file.name;
                file.addEventListener(Event.COMPLETE, completeHandler);
                // use the function to store a variable to let flash know you’ve selected an image
                // it’s also a good idea to have a text display of the filename the user selected
        }
        
function completeHandler(e:Event) {
    var loadimg = new Loader();
    loadimg.load(new URLRequest("http://www.myaddress.com/files/" + file.name));
    
}
function uploadMedia(e:Event){
    file.upload(new URLRequest("http://www.myaddress.com/upload_image.php"));
}

PHP Code


<?php
    if ($_FILES['Filedata']['name']) {
        move_uploaded_file($_FILES['Filedata']['tmp_name'], 'files/' . basename($_FILES['Filedata']['name']));
    }
?>



Any help would be appreciated.