Jump to content

file uploader


Ustag

Recommended Posts

Hi im trying to figure out how a file uploader works in flash.This is my code now:

import flash.events.MouseEvent;ulBtn.addEventListener(MouseEvent.CLICK, selectFile);function selectFile(event:MouseEvent):void{ var fileRef:FileReference = new FileReference(); fileRef.addEventListener(Event.SELECT, selectHandler); fileRef.addEventListener(Event.COMPLETE, completeHandler); try { var success:Boolean = fileRef.browse(); } catch (error:Error) { trace("Unable to browse for files."); } function selectHandler(event:Event):void { var request:URLRequest = new URLRequest("http://www.mycomain.com/upload.php"); try { fileRef.upload(request); } catch (error:Error) { trace("Unable to upload file."); } } function completeHandler(event:Event):void { trace("uploaded"); }}
This means that when I press ulBtn I get to pick a file that I should upload. Then it runs upload.php to add the file to the database and upload the file on the server but how do I know the file name variable for upload.php to add it to the database?
Link to comment
Share on other sites

  • 10 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...