Need help urgently regarding the uploading component in flex

View: New views
5 Messages — Rating Filter:   Alert me  

Need help urgently regarding the uploading component in flex

by santoshgadagoju :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I strucked at a point in designing uploading component in flex.
Below is the code of my uploading component. Please find the red marked
content in the below code.
My requirement is to alert the URL of the file selected in the list box
when i click a file item in the listbox.
Please help me ...


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="absolute"
creationComplete="initApp()">

     <mx:Style>
         Text{
             font-weight:    normal;
         }
         Label{
             font-weight:    bold;
         }

     </mx:Style>

     <mx:Script>
         <![CDATA[

         import mx.states.*;
             import mx.controls.*;
             import mx.managers.*;
             import mx.events.*;
             import mx.events.ListEvent;
             import flash.events.*;
             import flash.net.*;

             private var _arrUploadFiles:Array;
             private var _numCurrentUpload:Number = 0;
             private var _refAddFiles:FileReferenceList;
             private var _refUploadFile:FileReference;
             private var _strUploadUrl:String;



             private function initApp():void {
                 Security.allowDomain("*");
                 _arrUploadFiles = new Array();
             }

             // Set uploadUrl
             public function set uploadUrl(strUploadUrl:String):void {
                 _strUploadUrl = strUploadUrl;
             }

             private function addFiles():void {
                 _refAddFiles = new FileReferenceList();
                 _refAddFiles.addEventListener(Event.SELECT,
onSelectFile);
                 _refAddFiles.browse();
             }

             // Called to remove selected file(s) for upload
             private function removeFiles():void {
                 var arrSelected:Array = listFiles.selectedIndices;
                 for (var i:Number = 0; i < arrSelected.length; i++) {
                     _arrUploadFiles[Number(arrSelected[i])] = null;
                 }
                 for (var j:Number = 0; j < _arrUploadFiles.length; j++)
{
                     if (_arrUploadFiles[j] == null) {
                         _arrUploadFiles.splice(j, 1);
                         j--;
                     }
                 }
                 listFiles.dataProvider = _arrUploadFiles;
                 listFiles.selectedIndex = 0;

             }

             private function onSelectFile(event:Event):void {
                 var arrFoundList:Array = new Array();
                 // Get list of files from fileList, make list of files
already on upload list
                 for (var i:Number = 0; i < _arrUploadFiles.length; i++)
{
                     for (var j:Number = 0; j <
_refAddFiles.fileList.length; j++) {
                         if (_arrUploadFiles[i].label ==
_refAddFiles.fileList[j].name) {
                           
arrFoundList.push(_refAddFiles.fileList[j].name);
                             _refAddFiles.fileList.splice(j, 1);
                             j--;
                         }
                     }
                 }
                 if (_refAddFiles.fileList.length >= 1) {
                     for (var k:Number = 0; k <
_refAddFiles.fileList.length; k++) {
                       
_arrUploadFiles.push({label:_refAddFiles.fileList[k].name,
data:_refAddFiles.fileList[k]});
                     }
                     listFiles.dataProvider = _arrUploadFiles;
                     listFiles.selectedIndex = _arrUploadFiles.length -
1;
                 }
                 if (arrFoundList.length >= 1) {
                     Alert.show("The file(s): \n\n• " +
arrFoundList.join("\n• ") + "\n\n...are already on the upload list.
Please change the filename(s) or pick a different file.", "File(s)
already on list");
                 }

             }

             private function changeHandler(event:ListEvent):void{

                     Alert.show(event.itemRenderer.data.label);

                     // Here i want to alert the URL of the file clicked,
                     // i.e, URL of the file from where the file is
uploaded.
                 }


         ]]>
     </mx:Script>

     <mx:List id="listFiles" x="393" y="229" width="258"
itemClick="changeHandler(event)"/>
     <mx:Button x="659" y="239" label="Add" click="addFiles()" />
     <mx:Button x="659" y="269" label="Del" click="removeFiles()"/>


</mx:Application>


RE: Need help urgently regarding the uploading component in flex

by Alex Harui :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You didn't say what error or problem you are seeing.

 

________________________________

From: flexcomponents@...
[mailto:flexcomponents@...] On Behalf Of santoshgadagoju
Sent: Thursday, August 07, 2008 5:17 AM
To: flexcomponents@...
Subject: [flexcomponents] Need help urgently regarding the uploading
component in flex

 

I strucked at a point in designing uploading component in flex.
Below is the code of my uploading component. Please find the red marked
content in the below code.
My requirement is to alert the URL of the file selected in the list box
when i click a file item in the listbox.
Please help me ...


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="absolute"
creationComplete="initApp()">
   
    <mx:Style>
        Text{
            font-weight:    normal;    
        }
        Label{
            font-weight:    bold;    
        }
       
    </mx:Style>
   
    <mx:Script>
        <![CDATA[
       
        import mx.states.*;
            import mx.controls.*;
            import mx.managers.*;
            import mx.events.*;
            import mx.events.ListEvent;
            import flash.events.*;
            import flash.net.*;
       
            private var _arrUploadFiles:Array;
            private var _numCurrentUpload:Number = 0;
            private var _refAddFiles:

FileReferenceList;    
            private var _refUploadFile:FileReference;
            private var _strUploadUrl:String;
           
           
           
            private function initApp():void {
                Security.allowDomain("*");
                _arrUploadFiles = new Array();
            }    
           
            // Set uploadUrl
            public function set uploadUrl(strUploadUrl:String):void {
                _strUploadUrl = strUploadUrl;
            }
       
            private function addFiles():void {
                _refAddFiles = new FileReferenceList();
                _refAddFiles.addEventListener(Event.SELECT,
onSelectFile);
                _refAddFiles.browse();
            }
           
            // Called to remove selected file(s) for upload
            private function removeFiles():void {
                var arrSelected:Array = listFiles.selectedIndices;
                for (var i:Number = 0; i < arrSelected.length; i++) {
                    _arrUploadFiles[Number(arrSelected[i])] = null;
                }
                for (var j:Number = 0; j < _arrUploadFiles.length; j++)
{
                    if (_arrUploadFiles[j] == null) {
                        _arrUploadFiles.splice(j, 1);
                        j--;
                    }
                }
                listFiles.dataProvider = _arrUploadFiles;
                listFiles.selectedIndex = 0;
               
            }
           
            private function onSelectFile(event:Event):void {
                var arrFoundList:Array = new Array();
                // Get list of files from fileList, make list of files
already on upload list
                for (var i:Number = 0; i < _arrUploadFiles.length; i++)
{
                    for (var j:Number = 0; j <
_refAddFiles.fileList.length; j++) {
                        if (_arrUploadFiles[i].label ==
_refAddFiles.fileList[j].name) {
 
arrFoundList.push(_refAddFiles.fileList[j].name);
                            _refAddFiles.fileList.splice(j, 1);
                            j--;
                        }
                    }
                }
                if (_refAddFiles.fileList.length >= 1) {
                    for (var k:Number = 0; k <
_refAddFiles.fileList.length; k++) {
 
_arrUploadFiles.push({label:_refAddFiles.fileList[k].name,
data:_refAddFiles.fileList[k]});
                    }
                    listFiles.dataProvider = _arrUploadFiles;
                    listFiles.selectedIndex = _arrUploadFiles.length -
1;
                }                
                if (arrFoundList.length >= 1) {
                    Alert.show("The file(s): \n\n* " +
arrFoundList.join("\n* ") + "\n\n...are already on the upload list.
Please change the filename(s) or pick a different file.", "File(s)
already on list");
                }
               
            }
           
            private function changeHandler(event:ListEvent):void{
               
                    Alert.show(event.itemRenderer.data.label);
                   
                    // Here i want to alert the URL of the file clicked,
                    // i.e, URL of the file from where the file is
uploaded.
                }
               
           
        ]]>
    </mx:Script>
   
    <mx:List id="listFiles" x="393" y="229" width="258"
itemClick="changeHandler(event)"/>
    <mx:Button x="659" y="239" label="Add" click="addFiles()" />
    <mx:Button x="659" y="269" label="Del" click="removeFiles()"/>

   
</mx:Application>

 


Re: Need help urgently regarding the uploading component in flex

by hamza bakkali :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Could you explain your request please? *you need to alert the URL *


2008/8/12 Alex Harui <aharui@...>

>    You didn't say what error or problem you are seeing.
>
>
>  ------------------------------
>
> *From:* flexcomponents@... [mailto:
> flexcomponents@...] *On Behalf Of *santoshgadagoju
> *Sent:* Thursday, August 07, 2008 5:17 AM
> *To:* flexcomponents@...
> *Subject:* [flexcomponents] Need help urgently regarding the uploading
> component in flex
>
>
>
> I strucked at a point in designing uploading component in flex.
> Below is the code of my uploading component. Please find the red marked
> content in the below code.
> My requirement is to alert the URL of the file selected in the list box
> when i click a file item in the listbox.
> Please help me ...
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> layout="absolute" creationComplete="initApp()">
>
>     <mx:Style>
>         Text{
>             font-weight:    normal;
>         }
>         Label{
>             font-weight:    bold;
>         }
>
>     </mx:Style>
>
>     <mx:Script>
>         <![CDATA[
>
>         import mx.states.*;
>             import mx.controls.*;
>             import mx.managers.*;
>             import mx.events.*;
>             import mx.events.ListEvent;
>             import flash.events.*;
>             import flash.net.*;
>
>             private var _arrUploadFiles:Array;
>             private var _numCurrentUpload:Number = 0;
>             private var _refAddFiles:
>
> FileReferenceList;
>             private var _refUploadFile:FileReference;
>             private var _strUploadUrl:String;
>
>
>
>             private function initApp():void {
>                 Security.allowDomain("*");
>                 _arrUploadFiles = new Array();
>             }
>
>             // Set uploadUrl
>             public function set uploadUrl(strUploadUrl:String):void {
>                 _strUploadUrl = strUploadUrl;
>             }
>
>             private function addFiles():void {
>                 _refAddFiles = new FileReferenceList();
>                 _refAddFiles.addEventListener(Event.SELECT, onSelectFile);
>                 _refAddFiles.browse();
>             }
>
>             // Called to remove selected file(s) for upload
>             private function removeFiles():void {
>                 var arrSelected:Array = listFiles.selectedIndices;
>                 for (var i:Number = 0; i < arrSelected.length; i++) {
>                     _arrUploadFiles[Number(arrSelected[i])] = null;
>                 }
>                 for (var j:Number = 0; j < _arrUploadFiles.length; j++) {
>                     if (_arrUploadFiles[j] == null) {
>                         _arrUploadFiles.splice(j, 1);
>                         j--;
>                     }
>                 }
>                 listFiles.dataProvider = _arrUploadFiles;
>                 listFiles.selectedIndex = 0;
>
>             }
>
>             private function onSelectFile(event:Event):void {
>                 var arrFoundList:Array = new Array();
>                 // Get list of files from fileList, make list of files
> already on upload list
>                 for (var i:Number = 0; i < _arrUploadFiles.length; i++) {
>                     for (var j:Number = 0; j <
> _refAddFiles.fileList.length; j++) {
>                         if (_arrUploadFiles[i].label ==
> _refAddFiles.fileList[j].name) {
>
> arrFoundList.push(_refAddFiles.fileList[j].name);
>                             _refAddFiles.fileList.splice(j, 1);
>                             j--;
>                         }
>                     }
>                 }
>                 if (_refAddFiles.fileList.length >= 1) {
>                     for (var k:Number = 0; k <
> _refAddFiles.fileList.length; k++) {
>
> _arrUploadFiles.push({label:_refAddFiles.fileList[k].name,
> data:_refAddFiles.fileList[k]});
>                     }
>                     listFiles.dataProvider = _arrUploadFiles;
>                     listFiles.selectedIndex = _arrUploadFiles.length - 1;
>                 }
>                 if (arrFoundList.length >= 1) {
>                     Alert.show("The file(s): \n\n• " +
> arrFoundList.join("\n• ") + "\n\n...are already on the upload list. Please
> change the filename(s) or pick a different file.", "File(s) already on
> list");
>                 }
>
>             }
>
>             private function changeHandler(event:ListEvent):void{
>
>                     Alert.show(event.itemRenderer.data.label);
>
>                     // Here i want to alert the URL of the file clicked,
>                     // i.e, URL of the file from where the file is
> uploaded.
>                 }
>
>
>         ]]>
>     </mx:Script>
>
>     <mx:List id="listFiles" x="393" y="229" width="258"
> itemClick="changeHandler(event)"/>
>     <mx:Button x="659" y="239" label="Add" click="addFiles()" />
>     <mx:Button x="659" y="269" label="Del" click="removeFiles()"/>
>
>
> </mx:Application>
>
>  
>

Re: Need help urgently regarding the uploading component in flex

by santoshgadagoju :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My request is like, i just want to put an alert showing the url of the
uploaded file from where it is uploaded when i click an item in the
list of files.


Parent Message unknown RE: Re: Need help urgently regarding the uploading component in flex

by Tracy Spratt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I got my upload working using cookbook techniques and since it is
working I don't have time to figure out exactly what it is doing.

But I do display the selected File name after the user selects from the
File brows dialog box.  Note the line near the end, where I set the
textInput tiFileName.text.  You will need to analyze this code to
underestand what it is doing, I do not remember.

Note, you can NOT display the full path to the file on the local file
system, for security reasons.

Tracy

  // Called when a file is selected
  private function onSelectFile(event:Event):void {
    this.enabled = true;
    var arrFoundList:Array = new Array();
    if (bMultipleSelect)  {
      // Get list of files from fileList, make list of files already on
upload list
      for (var i:Number = 0; i < _aUploadFiles.length; i++) {
        for (var j:Number = 0; j < _refAddFiles.fileList.length; j++) {
          if (_aUploadFiles[i].label == _refAddFiles.fileList[j].name) {
            arrFoundList.push(_refAddFiles.fileList[j].name);
            _refAddFiles.fileList.splice(j, 1);
            j--;
          }
        }
      }//for (var i:Number
      if (_refAddFiles.fileList.length >= 1) {
        for (var k:Number = 0; k < _refAddFiles.fileList.length; k++) {
          _aUploadFiles.push({label:_refAddFiles.fileList[k].name,
data:_refAddFiles.fileList[k]});
        }
        listFiles.dataProvider = _aUploadFiles;
        listFiles.selectedIndex = _aUploadFiles.length - 1;
      }//if (_refAddFiles.        
      if (arrFoundList.length >= 1) {
        Alert.show("The file(s): \n\n* " + arrFoundList.join("\n* ") +
"\n\n...are already on the upload list. Please change the filename(s) or
pick a different file.", "File(s) already on list");
      }
      if (_aUploadFiles.length == 0) {
        btnUploadMultiple.enabled = false;
      } else {
        btnUploadMultiple.enabled = true;
      }      
    }
    else  {
      _aUploadFiles.push({label:_refAddFiles.fileList[0].name,
data:_refAddFiles.fileList[0]});
      tiFileName.text = _aUploadFiles[0].label;
      //btnUploadSingle.enabled = true;
    }//

  }//onSelectFile

-----Original Message-----
From: flexcomponents@...
[mailto:flexcomponents@...] On Behalf Of santoshgadagoju
Sent: Wednesday, August 20, 2008 1:34 PM
To: flexcomponents@...
Subject: [flexcomponents] Re: Need help urgently regarding the uploading
component in flex

My request is like, i just want to put an alert showing the url of the
uploaded file from where it is uploaded when i click an item in the
list of files.


------------------------------------

Yahoo! Groups Links





LightInTheBox - Buy quality products at wholesale price!