# Uploading Files using FileReference Tutorial

**URL:** https://forum.kirupa.com/t/uploading-files-using-filereference-tutorial/215308
**Category:** flash
**Created:** [February 6, 2007, 6:13am UTC](https://forum.kirupa.com/t/uploading-files-using-filereference-tutorial/215308 "2007-02-06T06:13:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![DeepSoul](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@DeepSoul](https://forum.kirupa.com/u/DeepSoul)
#### Post date: [February 6, 2007, 6:13am UTC](https://forum.kirupa.com/t/uploading-files-using-filereference-tutorial/215308/1 "2007-02-06T06:13:08Z")

</div>

I’ve done the tutorial “ **Uploading** Files using FileReference” , and i think i did all good…the actionscript is this:

[COLOR=blue]import flash.net.FileReference;  
var progressBar:MovieClip;  
var reference:FileReference = new FileReference();  
var referenceListener:Object = {};  
var scriptLocation:String = ‘uploader.php’;  
var progressBarHeight:Number = 10;  
var progressBarY:Number = 50;  
var progressBarColor:Number = 0x66ccff;  
uploadButton\_mc.\_visible = false;  
reference.addListener(referenceListener);  
referenceListener.onSelect = activateUploadButton;  
referenceListener.onProgress = updateProgress;  
referenceListener.onComplete = restart;  
referenceListener.onHTTPError = handleError;  
referenceListener.onIOError = handleError;  
referenceListener.onSecurityError = handleError;  
chooseButton\_mc.onRelease = choose;  
uploadButton\_mc.onRelease = uploadCurrent;  
function activateUploadButton():Void {  
display\_txt.text = reference.name;  
uploadButton\_mc.\_visible = true;  
}  
function choose():Void {  
reference.browse([{description:‘All Files (_._)’, extension:’_._’}]);  
}  
function handleError(errorName:String, detail:Object):Void {  
restart();  
if (arguments.length === 2) {  
if (typeof detail === ‘number’) {  
display\_txt.text = ‘HTTP Error #’+detail;  
} else {  
display\_txt.text = 'Security Error: ‘+detail;  
}  
} else {  
display\_txt.text = ‘IO Error’;  
}  
}  
function makeProgressBar(x:Number, y:Number):MovieClip {  
var bar:MovieClip = createEmptyMovieClip(‘progressBar\_mc’, 0);  
bar.\_visible = false;  
bar.beginFill(progressBarColor);  
bar.lineTo(Stage.width, 0);  
bar.lineTo(Stage.width, progressBarHeight);  
bar.lineTo(0, progressBarHeight);  
bar.lineTo(0, 0);  
bar.endFill();  
bar.\_width = 0;  
bar.\_visible = true;  
bar.\_x = x;  
bar.\_y = y;  
return bar;  
}  
function restart():Void {  
removeMovieClip(progressBar);  
display\_txt.text = ‘’;  
uploadButton\_mc.\_visible = false;  
chooseButton\_mc.\_visible = true;  
}  
function updateProgress(fileReference:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {  
display\_txt.text = fileReference.name+’ - '+Math.ceil((bytesLoaded/bytesTotal)_100)+’%’;  
progressBar.\_width = Math.ceil(Stage.width_(bytesLoaded/bytesTotal));  
}  
function uploadCurrent():Void {  
chooseButton\_mc.\_visible = false;  
progressBar = makeProgressBar(0, progressBarY);  
reference.upload(scriptLocation);  
}  
[/COLOR]

And the uploader.php script is this:

[COLOR=blue]\<?php  
if ($\_FILES[‘Filedata’][‘name’]) {  
move\_uploaded\_file($\_FILES[‘Filedata’][‘tmp\_name’], ‘upload\_directory/’ . basename($\_FILES[‘Filedata’][‘name’]));  
}  
?\>[/COLOR]

I have upload all in my server and create the “upload\_directory”, and testing it, it seems upload the file, the scrollbar goes to 100%, but after this it gives me back this error: [COLOR=red]HTTP Error #403[/COLOR] ,but all looks whel done to me, so who can help me?

---

<div class="post-metadata">

### Author: ![Genius\_cd](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@Genius\_cd](https://forum.kirupa.com/u/Genius_cd)
#### Post date: [June 26, 2008, 3:07pm UTC](https://forum.kirupa.com/t/uploading-files-using-filereference-tutorial/215308/2 "2008-06-26T15:07:21Z")

</div>

yeahhhhhhhhhhhhhhhhhh…same problem over here!!!

i’ve been working since one week!!! error 403…  
i can’t get it fixed!!!  
anyone!
