Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the function of uploading files on Flex

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

In this issue, the editor will bring you about how to achieve the function of uploading files on Flex. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

Wrote a lot of file upload functions, including AJAX to achieve dynamic monitoring of upload progress, now see the realization of Flex file upload function, is really very convenient, here to share with you.

Flex upload file function

I have written a lot of file upload features, including AJAX to dynamically monitor the upload progress. Now we can see that it is very convenient to implement the Flex file upload function. There is nothing to say. Flex upload file code:

Upload.mxml

.myfont {font-size:13pt}

Upload.as

1//ActionScriptfile 2importflash.events.Event.3importflash.net.FileFileFileFilter; 4importflash.net.FileReference; 5privatevarfileRef:FileReference=newFileReference (); 6privatefunctioninit (): void {7 8} 9 10privatefunctionpickfile (): void {11varimageTypes:FileFilter=newFileFilter ("Pictures (* .jpg, * .FileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFile; void {7 8} 9 Events (): void {11varimageTypes:FileFilter=newFileFilter (" Pictures (* .jpg, * .FileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFileFil 13varofficeType:FileFilter=newFileFilter ("Office files (* .doc, * .xls", "* .doc;*.xls"); 14varanyType:FileFilter=newFileFilter ("all files (*. *)", "*. *"); 15varallTypes:Array=newArray (imageTypes,textTypes,officeType,anyType); 16fileRef.addEventListener (Event.SELECT,selectHandler); 17fileRef.addEventListener (Event.COMPLETE,completeHandler); 18fileRef.addEventListener (ProgressEvent.PROGRESS,progressHandler); 19fileRef.addEventListener ("ioError", ioerrorHandler); 20try {21varsuccess:Boolean=fileRef.browse (allTypes) 22} catch (error:Error) {23trace ("Unabletobrowseforfiles." + error.toString ()); 24} 25} 26privatefunctionioerrorHandler (event:Event): void {27trace ("Unabletouploadfile." + event.toString ()); 28} 29privatefunctionprogressHandler (event:ProgressEvent): void {30lbProgress.text= "uploaded" + (event.bytesLoaded/1024) .tofixed (2) + K, total + (event.bytesTotal/1024) .fixed (2) + "K"; 31varproc:uint=event.bytesLoaded/event.bytesTotal*100 32progress1.setProgress (proc,100); 33} s1.label = "current progress:" + "+ proc+"% "; 34 35} 36privatefunctionselectHandler (event:Event): void {37varrequest:URLRequest=newURLRequest (" http://localhost:9080/upload/upload.jsp") 38try 39 {40fileRef.upload (request); 41} 42catch (error:Error) 43 {44trace ("Unabletouploadfile." + error.toString ()); 45} 46} 47privatefunctioncompleteHandler (event:Event): void {48trace ("uploaded"); 49}

Effect of uploading files on Flex:

The above is the editor for you to share the Flex file upload function how to achieve, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report