4 Replies Latest reply on Feb 20, 2010 7:43 AM by venkatsyss

    Regarding - Image

    venkatsyss Level 1

      hi,

       

      My question is , after uploaded the image,the image is fails to display in  the datagrid.Why because the page is not refreshing..

       

      Please provide me the solution to solve the problem.

       

      The Following script i have used to upload the image.

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
      creationComplete="init();userRequest.send();">
      <mx:HTTPService id="userRequest" url="uploadFile.php" method="POST"
      useProxy="false">

      </mx:HTTPService>
           <mx:Script>
               <![CDATA[
                   import mx.rpc.events.ResultEvent;

                  private var urlRequest:URLRequest;
                   private var fileReferenceList:FileReferenceList;
                   private var serverSideScript:String = "uploadFile.php";

                  private function init():void {
                       urlRequest = new URLRequest(serverSideScript);
                       fileReferenceList = new FileReferenceList();
                       fileReferenceList.addEventListener(Event.SELECT,
      fileSelectedHandler);
                   }

                  private function uploadFile():void {
                       fileReferenceList.browse();

                  }

                  private function fileSelectedHandler(event:Event):void {
                       var fileReference:FileReference;
                       var fileReferenceList:FileReferenceList =
      FileReferenceList(event.target);
                       var fileList:Array = fileReferenceList.fileList;

                      // get the first file that the user chose
                       fileReference = FileReference(fileList[0]);

                      // upload the file to the server side script
                       fileReference.addEventListener(Event.COMPLETE,
      uploadCompleteHandler);
                       fileReference.upload(urlRequest);

                      // update the status text
                       statusText.text = "Uploading...";
                   }

                  private function uploadCompleteHandler(event:Event):void {
                       statusText.text = "File Uploaded: " +
      event.target.name;
                       currentState="temp";
                   }

              ]]>

          </mx:Script>

          <mx:Label text="Upload File From Flex to PHP" fontWeight="bold"/>
           <mx:Label text="Choose a file..." id="statusText"/>
           <mx:Button click="uploadFile();" label="Upload File"/>

       

       

       

      Thanks and Regards,

      venkat.R

        • 1. Re: Regarding - Image
          Vikram_S Level 2

          Hi Venkat,

                you haven't mentioned code of datagrid in post.

          Thanks,

          Vikram

          • 2. Re: Regarding - Image
            venkatsyss Level 1

            hi,

             

            Thanks for your kind reply.

             

            The above code shows the datagrid for your kind persual.

            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            creationComplete="init();userRequest.send();">
            <mx:HTTPService id="userRequest" url="uploadFile.php" method="POST"
            useProxy="false">
            </mx:HTTPService>

            <mx:states>
                 <mx:State name="temp">
                 <mx:AddChild>
                   <mx:DataGrid x="10" y="10" width="443" height="176"  dataProvider="{userRequest.lastResult.users.user}" id="dgPhoto">
                                        <mx:columns>

                                                <mx:DataGridColumn
            headerText="Preview" dataField="img">
                                                 <mx:itemRenderer>
                     <mx:Component>
                     <mx:VBox>
                     <mx:Image source="path/{data.img}" width="100%" height="100"
            horizontalAlign="center"/>
                     </mx:VBox>
                     </mx:Component>
                     </mx:itemRenderer>
                     </mx:DataGridColumn>
                 </mx:columns>
                 </mx:DataGrid>
                 </mx:AddChild>

                </mx:State>

             

                </mx:states>

             

                </mx:Application>

             

            //This is the Query i have used in PHP

             

            $answer="select * from tbl_image";
            $result=mysql_query($answer);
            print "<users>";
            while($row=mysql_fetch_object($result)){

                print "<user>
                  <img>".$row->img_name."</img>

                </user>";

            }

             

            Please provide me the solutions to solve the problem.

             

            Thanks and Regards,

            venkat.R

            • 3. Re: Regarding - Image
              Gregory Lafrance Level 6

              Is the data coming back correct and valid?

               

              What actually displays?

              • 4. Re: Regarding - Image
                venkatsyss Level 1

                hi,

                 

                Thanks for your reply.

                 

                The Data is not retrieved why because the page is not refreshed after uploaded an image.

                 

                 

                Please provide me a solution to solve a problem.

                 

                 

                Thanks and Regards,

                venkat.R