Upload files from Flash to server


I am making a Flash application that is uploading files(images, videos, sounds) to a server. I am trying to use the fileReference.upload(urlRequest) function, but it looks like there is something wrong. I get a ProgressEvent.PROGRESS event which says that “bytesLoaded=4680149, bytesTotal=4680149”. From this it looks like everything is uploaded, but from the server side nothing is.
I probably do something wrong with the filerefernce or something, but I dont know what…

The function that browse and upload files:

        var filter:Array<FileFilter> = new Array<FileFilter>();
		filter.push(new FileFilter("MP3 Files (*.mp3)", "*.mp3"));
	}else if(fileType=="video"){
		filter.push(new FileFilter ("Video Files (*.mov, *.mp4)", "*.mov; *.mp4"));
	}else if(fileType=="image"){
		filter.push(new FileFilter ("Images (*.jpg, *.jpeg, *.png)", "*.jpg; *.jpeg; *.png"));
	var fr:FileReference = new FileReference();
	var urlloader:URLLoader = new URLLoader();
	fr.addEventListener(Event.SELECT, function(e){
                var fr:FileReference = e.target;
		fr.addEventListener(ProgressEvent.PROGRESS, onProgress);
		fr.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, onComplete);
		fr.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
		fr.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatus);
		fr.addEventListener(Event.CANCEL, onCancel);
		try {
    		       fr.upload(urlRequest); //maybe add fr.upload(urlRequest, fr.name,false); instead
    	        } catch (error:Dynamic) {
   		        titleLevel1.text=""+ error;
        //This function open the file dialog box where the user can choose a file

Please help!

What security sandbox is the SWF compiled for? Perhaps you need to use -Dnetwork-sandbox (or something) in order for this to work?