# Clearing out an uploaded file using fileSelect (to replace it with a new one)

**URL:** <https://forum.kirupa.com/t/clearing-out-an-uploaded-file-using-fileselect-to-replace-it-with-a-new-one/323313>\
**Category:** flash\
**Created:** [June 24, 2011, 8:17pm UTC](https://forum.kirupa.com/t/clearing-out-an-uploaded-file-using-fileselect-to-replace-it-with-a-new-one/323313 "2011-06-24T20:17:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![O\_Tamandua](https://avatars.discourse-cdn.com/v4/letter/o/ecccb3/32.png) [@O\_Tamandua](https://forum.kirupa.com/u/O_Tamandua)\
**Post date:** [June 24, 2011, 8:17pm UTC](https://forum.kirupa.com/t/clearing-out-an-uploaded-file-using-fileselect-to-replace-it-with-a-new-one/323313/1 "2011-06-24T20:17:18Z")

</div>

SOLVED! Thanks and God bless, BenBart.

Hello, all. This should be easy.

I’ve got a file upload (for art) function on my application that works…but whenever you load a .jpg or .png file into the designnated movie clip (chip\_clip) then upload another the original file isn’t cleared out and they’re meshed atop one another. I just want to be able to have any existing file in “chip\_clip” unloaded and replaced by any new one.

“Browse” is the button which calls this function. Thanks in advance for any advice:

> 

var file:FileReference = new FileReference();  
file.addEventListener(Event.SELECT, fileSelect);  
file.addEventListener(Event.COMPLETE, fileComplete);  
var loader:Loader = new Loader();  
browse.addEventListener(MouseEvent.MOUSE\_DOWN,function(){  
loader.unloadAndStop();  
});  
browse.addEventListener(MouseEvent.MOUSE\_DOWN, mouseDown);  
function mouseDown(event:MouseEvent)  
{  
file.browse();  
}  
function fileSelect(event:Event)  
{  
file.load();  
}  
function fileComplete(event:Event)  
{  
//var loader:Loader = new Loader();  
loader.loadBytes(file.data);  
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);  
}  
function onCompleteHandler(event:Event):void  
{  
chip\_clip.addChild(event.target.content);  
event.target.content.width = 90;  
event.target.content.scaleY = event.target.content.scaleX;  
}
