0 Replies Latest reply on Apr 23, 2010 5:33 AM by Jotajota-br

    FLEX + PHP (Problem with upload file by ftp)

    Jotajota-br

      I develop a system in windows environment but I run it in a Linux server.

      I have a functionality that can be upload of files but it isn't to work well.

       

      this is my code:

      IN upload.mxml - when I click on the button

       

                  private function loadImage():void{
                     
                      try {
                          var success:Boolean = fileRef.browse();
                      }
                      catch (error:Error) {
                          trace("Unable to browse for files.");
                      }
                  }   

       

      When I save my datas the code call other funcion to finish the upload :

       

                  public function uploadFile():void {
                     
                      var request:URLRequest = new URLRequest("file_upload.php?path=news")
                      try {
                          fileRef.upload(request);
                      }
                      catch (error:Error){
                          trace("Unable to upload file.");
                      }
                  }

       

      This is my file_upload.php

       

       

       

      <?php


          $file_temp    = $_FILES['Filedata']['tmp_name'];
          $file_name    = $_FILES['Filedata']['name'];
         
          $path = $_REQUEST['path'];  
         
          move_uploaded_file($file_temp,"./$path/".$file_name);//copy in local project

       


      $resultado = "nada";
          $host = "127.0.0.1"   
          $ftp = ftp_ssl_connect("$host");
         
          $login_result =  ftp_login($ftp, "ftp_login", "ftp_pass");
         

       

          if (ftp_put($ftp, "$file_temp", "$file_name", FTP_BINARY)){
              $resultado ="sucessfully";
          }else{
              $resultado = "fail_FTP";
          }
          echo $resultado;   
          ftp_close($ftp);
         
      ?>

       

      Please, I dont understand why this simple code dont work. Can anyone help me?