0 Replies Latest reply on Aug 23, 2012 11:01 AM by iamcootis

    Problem uploading a file using ZendAMF

    iamcootis Level 1

      I am trying to upload a file using ZendAMF PHP DataService, but I keep getting an error. "

      Channel disconnected

      Channel disconnected before an acknowledgement was received

      "

        

        private var fr:FileReference = new FileReference();
                  
                  private function loadImage(): void
                  {
                      fr.addEventListener(Event.SELECT, selectedImage);
                      fr.addEventListener(Event.COMPLETE,getImage);
                      var imagesFilter:FileFilter = new FileFilter("Images", "*.jpg;*.gif;*.png");
                      fr.browse([imagesFilter]);
                  }
                  
                  private function selectedImage(e:Event): void
                  {
                      fr.removeEventListener(Event.SELECT, selectedImage);
                      fr.load(); 
                  }
                  
                  private function getImage(e:Event): void
                  {
                      fr.removeEventListener(Event.COMPLETE, getImage);
                      localimgResult2.token = uploader.localimg(fr.data,fr.name);
                  }
                  
                  private function onFault(e:FaultEvent): void
                  {
                      Alert.show(e.message.toString(),"Error");
                  }
                  
                  private function isImageUploaded(e:ResultEvent): void
                  {
                      Alert.show(e.message.toString(),"Result");
                  }
      
      
      <s:CallResponder id="localimgResult2" result="isImageUploaded(event)"/>
              <uploader:Uploader id="uploader" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
      

       

       

      And my PHP code looks like this: I'm using php 5.3.8

       

      function localimg($ba,$fname) {
          $deffilepath = '../images/'.$fname;    
          $data = $ba->data;
          file_put_contents($deffilepath, $data);
          return ("done");
          }
      

      }