title: PHP Curl Error code 25
body: <p>I tried to search the web but I couldn't find a clear point on the issue I'm trying to figure out.</p>
  
  <p>I have a situation where the uploaded files will be sent over to another server via FTP (Egnyte). I have a localhost setup and it succeeded uploading the files to FTP but not in the live site where it gives me a curl error (25)  - in FTP, STOR command has been denied. It has a further error message of "Failed FTP upload: 451". What bugs me even more is, the server has staging / dev cloned from the live site and it perfectly works there.</p>
  
  <p>What could be in the localhost setup that I should look in the server of the live site and/or possible causes of the curl error? Curl is enabled in the live server btw.</p>
  
  <p>My curl options (considering variables are supplied properly and ftp has been connected):</p>
  
  <pre><code>// connection options
      $options = array(
          CURLOPT_USERPWD        =&gt; $username . ':' . $password,
          CURLOPT_SSL_VERIFYPEER =&gt; false, // don't verify SSL
          CURLOPT_SSL_VERIFYHOST =&gt; false,
          CURLOPT_FTP_SSL        =&gt; CURLFTPSSL_ALL, // require SSL For both control and data connections
          CURLOPT_FTPSSLAUTH     =&gt; CURLFTPAUTH_DEFAULT, // let cURL choose the FTP authentication method (either SSL or TLS)
          CURLOPT_UPLOAD         =&gt; true,
          CURLOPT_PORT           =&gt; $port,
          CURLOPT_TIMEOUT        =&gt; 30,
      );
  </code></pre>
  
  <p>and here's my upload function: </p>
  
  <pre><code>public function upload( $file_name, $file ) {
  
      // set file name
      if ( ! curl_setopt( $this-&gt;curl_handle, CURLOPT_URL, $this-&gt;url . $file_name ))
          throw new Exception ( "Could not set cURL file name: $file_name" );
  
      /* Open the file for writing  */
      $file_stream = fopen($file, "r");
  
      /* Open a memory for writing */
      $stream = fopen('php://temp' , "wb");
  
      /* Read the file and write it to the stream 1kb at a time */
      while ($data = fread($file_stream, 1024))
          fwrite($stream, $data);
  
      // rewind the stream pointer
      rewind( $stream );
  
      // set the file to be uploaded
      if ( ! curl_setopt( $this-&gt;curl_handle, CURLOPT_INFILE, $stream ) )
          throw new Exception( "Could not load file $file_name" );
  
      // upload file
      if ( ! curl_exec( $this-&gt;curl_handle ) ) {
          throw new Exception( sprintf( 'Could not upload file. cURL Error: [%s] - %s', curl_errno( $this-&gt;curl_handle ), curl_error( $this-&gt;curl_handle ) ) );
      }
  
      // close the stream handle
      fclose( $stream );
      fclose( $file_stream );
  }
  </code></pre>