NEED HELP TO UPLOAD THE DIRECTORY ON MY FTP SERVER HOW?USING PHP

    [man]ftp[/man]

    PS: If you hit the "CAPS LOCK" key so that the little light turns off on you keyboard, then you won't be SHOUTING at us any more.

      i dinr the following code
      but it gives me error which is i cant understand why

      this code basccally upload a directory from my computer to ftp server
      coneection is ok but there is some problom with syntax or logic.
      all code and form is following



      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

      
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Untitled Document</title>
      </head>
      
      <body>
      <form  method="post" action="upload.php">
      
      Move or Upload Folder  Using PHP FTP Functions<br />
        </p>
        <table width="373" border="1">
          <tr>
            <td width="184">server address </td>
            <td width="173"><input type="text" id="server_name" name="server_name" /></td>
          </tr>
          <tr>
            <td>user name </td>
            <td><input type="text" name="user_name" id="user_name" /></td>
          </tr>
          <tr>
            <td>user password</td>
            <td><input type="text" id="user_password" name="user_password" /></td>
          </tr>
          <tr>
            <td>local directory</td>
            <td><input type="text" name="local_dir" id="local_dir" /></td>
          </tr>
          <tr>
            <td>remote directory</td>
            <td><input type="text" name="remote_dir" id="remote_dir" /></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input name="upload"  type="submit" id="upload"   /></td>
          </tr>
        </table>
        <p>&nbsp;  </p>
      </form>
      
      
      
      
      
      </body>
      </html>
      
      
      

      ..........................................
      this code catching the values from the orm and calling the functions "upload function.pho"

      
      
      <?php 
      // Start the session
        session_start();
        header("Cache-control: private"); //IE 6 Fix
      
      $_server = $_POST["server_name"];
      $_user_name = $_POST["user_name"];
      $_user_pass = $_POST["user_password"];
      $local_dir = $_POST["local_dir"];
      $remote_dir = $_POST["remote_dir"];
      
      
      
      require ("uploadfunctionpage.php");
      
      
      
      $uploadfunction = moveFolder($_server, $_user_name, $_user_pass, $local_dir, $remote_dir);
      
      if($uploadfunction=true)
      {
      echo " successfull";
      }
      else
      {
      echo "failed";
      }
      
      
      
      ?>
      
      

      .........................

      here is fuction who all works ans have some problom

      <?php 
      
      //Move or Upload Folder Using PHP FTP Functions
      function moveFolder($_server, $_user_name, $_user_pass, $local_dir, $remote_dir) {
      
      echo"$_user_name <br/>";
      echo"$_user_pass <br/>";
      echo" directories are : <br/>";
      echo"$local_dir<br/>";
      echo"$remote_dir <br/>";
      
      // set up basic connection
      $_conn_id = ftp_connect($_server);
      
      // login with username and password
      $_login_result = ftp_login($_conn_id, $_user_name, $_user_pass);
      
      // check connection
      if ((!$_conn_id) || (!$_login_result)) {
      $_error = "FTP connection has failed!";
      $_error .= "Attempted to connect to $_server for user $_user_name";
      $result = false;
      } else {
      $_error = "Connected to $_server, for user $_user_name";
      }
      
      $conn_id = $_conn_id;
      
      
      @ftp_mkdir($conn_id, $remote_dir);
      echo "successfully created $remote_dir\n";
      
      $handle = opendir($local_dir);
      while (($file = readdir($handle)) !== false) {
      if (($file != '.') && ($file != '..')) {
      if (is_dir($local_dir . $file)) {
      //recursive call
      moveFolder($conn_id, $local_dir . $file . '/', $remote_dir . $file . '/');
      echo "successfully uploaded $file\n";
      } else
      $f[] = $file;
      }
      
      }
      
      
      closedir($handle);
      if (count($f)) {
      sort($f);
      @ftp_chdir($conn_id, $remote_dir);
      foreach ($f as $files) {
      $from = @fopen("$local_dir$files", 'r+');
      $moveFolder = ftp_fput($conn_id, $files, $from, FTP_ASCII);
      // @ftp_fput($conn_id, $files, $from, FTP_BINARY);
      // check upload status
      if (!$moveFolder) {
      $this->_error = "FTP upload has failed! From:" . $local_dir . " To: " . $remote_dir;
      $result = false;
      } else {
      $this->_error = "Uploaded $local_dir to $remote_dir as $this->_server";
      $result = true;
      }
      }
      }
      return $result;
      }
      ?>
      
      
      

        can you give me the answer that how to resolve this issue
        hanks

          13 days later

          waiting from long time but no help recived .
          mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm

            Try telling us what the error is and what you have done to try and find out what is causing it. I for one don't have time to go crawling through all that code looking for an error that may or may not be there. What have you done about it in the past three weeks?

              Write a Reply...