hi,

How i have to write server side script file(.net).
This handler file, where i have to store in server?

Thanks
Prakash


On Sun, Apr 5, 2009 at 12:20 PM, Flex Baby <[email protected]>wrote:

>
> Flex:
> <mx:Script>
>                <![CDATA[
>                        import mx.controls.*;
>            import mx.managers.*;
>            import mx.events.*;
>            import flash.events.*;
>            import flash.net.*;
>            import com.esri.solutions.flexviewer.utils.WidgetEffects;
>            import
> com.esri.solutions.flexviewer.utils.DataGridDataExporter;
>            import mx.collections.*;
>             import flash.net.URLRequest;
>             import flash.net.URLRequestMethod;
>             import flash.net.FileReference;
>        // import com.esri.aims.mtier.model.util.FileUpload
>            private const ICON_URL:String = "com/esri/solutions/
> flexviewer/assets/images/icons/";
>             private var __file:FileReference;
>             private var _dirname:String;
>             private var brow:String;
>            private const UPLOAD_URL:String = "http://localhost/
> flex_sample_upload/Handler.ashx<http://localhost/%0Aflex_sample_upload/Handler.ashx>
> ";
>
>
>            private function init():void
>            {
>                __file = new FileReference();
>
>        __file.addEventListener(Event.SELECT                  ,
> __fileSelectionHandler);
>        __file.addEventListener(Event.COMPLETE                ,
> __completeHandler     );
>        __file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,
> __uploadDataHandler   );
>                //fileRef = new FileReference();
>
>        //fileRef.addEventListener(Event.SELECT ,SelectionHandler);
>       //fileRef.addEventListener(Event.COMPLETE,completeHandler);
>        //fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,
> __uploadDataHandler   );
>                wTemplate.addTitlebarButton(ICON_URL + "i_table.png",
> null, showStateResults);
>                                wTemplate.addTitlebarButton(ICON_URL +
> "i_pushpin.png", null,
> showStateCoordinates);
>                                wTemplate.addTitlebarButton(ICON_URL +
> "i_mailbox.png", null,
> showStateAddress);
>            }
>
>            private function showStateAddress(event:MouseEvent):void
>                        {
>                                WidgetEffects.flipWidget(this, viewStack,
> "selectedIndex", 0,
> 400);
>                        }
>
>                        private function
> showStateCoordinates(event:MouseEvent):void
>                        {
>                                WidgetEffects.flipWidget(this, viewStack,
> "selectedIndex", 1,
> 400);
>                        }
>
>                        private function
> showStateResults(event:MouseEvent):void
>                        {
>                                WidgetEffects.flipWidget(this, viewStack,
> "selectedIndex", 2,
> 400);
>                        }
>
>            private function __onBrowse():void
>      {
>        try
>        {
>          var success:Boolean = __file.browse();
>        }
>        catch (error:Error)
>        {
>                Alert.show("Status: Unable to open browse dialog");
>         // __status__.text = "Status: Unable to open browse
> dialog";
>        }
>      }
>
>
>           /*  private function onSelectFile(event:Event):void
>            {
>
>                browse.text = fileRef.name;
>                brow=browse.text;
>            }  */
>
>          private function __onUpload():void
>      {
>        // replace with URL to your upload handler - THIS ONE WON'T
> WORK!!!!
>        var myRequest:URLRequest = new URLRequest("http://localhost/
> flex_sample_upload/Handler.ashx<http://localhost/%0Aflex_sample_upload/Handler.ashx>
> ");
>
>        myRequest.method         = URLRequestMethod.POST;
>
>        try
>        {
>          __file.upload(myRequest);
>         // __status__.text = "Status: Now uploading " + __file.name +
> " ... ";
>          // Alert.show("Now uploading");
>        }
>        catch (error:Error)
>        {
>        //  __status__.text = "Status: Error uploading " +
> __file.name;
>        Alert.show("Error uploading");
>        }
>      }
>       private function __fileSelectionHandler(_e:Event):void
>      {
>        __upload__.enabled = true;
>
>       __uploadFile__.text = __file.name;
>        //__uploadFile__.text     = "Status:  Click 'Upload' to begin
> file upload";
>      }
>
>      private function __completeHandler(_e:Event):void
>      {
>        // nothing currently done in this handler - experiment and
> have fun :)
>      }
>
>      private function __uploadDataHandler(_e:DataEvent):void
>            {
>        var myResult:XML = new XML(_e.data);
>                   // __status__.text  = "File Upload Complete \n" +
> myResult.toString();
>                     Alert.show("File Upload Complete");
>
>            }
>         /*
>          <mx:HTTPService url="http://localhost/flex_sample_upload/
> Handler.ashx" id="login_user" method="POST"
>
>     useProxy="false">
>
>    <mx:request xmlns="">
>        <brow>
>                                {username1.text}
>                        </brow>
>          } */
>                ]]>
>        </mx:Script>
>
>  <mx:Canvas >
>                                 <mx:Label id="lab" text=" 1.Locate Excel
> File"
> color="white"   fontSize="14"/>
>
>                                 <mx:HBox x="5" y="31" width="100%">
>                                <!--     <mx:TextInput id="__status__"/>-->
>                                 <mx:Button id="__browse__" toolTip="Add
> file(s)"
> click="__onBrowse();"
>                                                 label="Browse"/>
>                                 <mx:Button id="__upload__" label="Upload"
> click="__onUpload
> ();"/>
>                                 <mx:TextInput id="__uploadFile__"
> editable="false"
> enabled="true"/>
>                                   </mx:HBox>
>                                 <mx:HBox x="13.5" y="61" width="100%">
>                                        <mx:LinkButton label="Click here"
> id="sample_link"
> color="white"/>
>                                        <mx:Label text="for Sample file."
> width="156"
> id="sample_label" color="white"/>
>                                 </mx:HBox>
>
>                                   </mx:Canvas>
> Asp.net:
>
> this is web handler fiile
>
> <%@ WebHandler Language="C#" Class="Uploader" %>
>
> using System.IO;
> using System.Web;
> using System.Web.Configuration;
>
> public class Uploader : IHttpHandler
> {
>  public void ProcessRequest( HttpContext _context )
>                {
>                  // not very elegant - change to full path of your upload
> folder
> (there are no upload folders on my site)
>    string uploadDir = "C:\\temp";
>
>    if (_context.Request.Files.Count == 0)
>    {
>      _context.Response.Write("<result><status>Error</
> status><message>No files selected</message></result>");
>      return;
>    }
>
>    foreach(string fileKey in _context.Request.Files)
>    {
>      HttpPostedFile file = _context.Request.Files[fileKey];
>      file.SaveAs(Path.Combine(uploadDir, file.FileName));
>    }
>
>    _context.Response.Write("<result><status>Success</
> status><message>Upload completed</message></result>");
>  }
>
>  public bool IsReusable
>                {
>    get { return true; }
>  }
> }
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to