# Problem with FileReference and LoadVars Together

**URL:** <https://forum.kirupa.com/t/problem-with-filereference-and-loadvars-together/235816>\
**Category:** flash\
**Created:** [August 14, 2007, 10:32pm UTC](https://forum.kirupa.com/t/problem-with-filereference-and-loadvars-together/235816 "2007-08-14T22:32:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![daheroes](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@daheroes](https://forum.kirupa.com/u/daheroes)\
**Post date:** [August 14, 2007, 10:32pm UTC](https://forum.kirupa.com/t/problem-with-filereference-and-loadvars-together/235816/1 "2007-08-14T22:32:22Z")

</div>

Hi there.

I am currently trying to build a small thing in flash that prompts people to enter their name and some personal details, and upload a picture.

I can do either of these operations just fine by itself, but my question comes down to doing both at the same time.

I use a LoadVars object to upload the values of the TextFields:

```auto

var uploadObj:LoadVars = new LoadVars();
var nameSuccess = false;
var locationSuccess = false;
if(nameBox.text == ""){
	messageBox.text = "Please provide a name.
";
	nameSuccess = true;
} else {
	uploadObj.name = nameBox.text;
}
if(locationBox.text == ""){
	messageBox.text += "Please say where you are from.
";
	locationSuccess = true;
} else {
	uploadObj.location = locationBox.text;
}
if(nameSuccess && locationSuccess){
	uploadObj.sendAndLoad("upload.php", uploadObj, "POST");
}

```

And I use a FileReference object to upload the image file:

```auto

listener.onSelect = function(selectedFile:FileReference):Void {
	selectedFile.upload("uploadFile.php");
}

```

But my only question is how do I submit both of them at once? Right now the code works through a listener, and uploads once the file is selected (onSelect).

Maybe I’m just missing something really basic, but I can’t seem to figure out a way to submit both the image and the vars in the same call.

And I’ve looked all over the forums and the site for any info.

Any help would be greatly appreciated.

Cheers,

Brekk
