Jump to content

ftp_put permission denied problem


ballhogjoni

Recommended Posts

I am getting this error Warning: ftp_put() [function.ftp-put]: Can't open that file: Permission denied in /home/chris/public_html/site-name/wp-content/setup.php on line 62

 

$conn_id = ftp_connect($host, 21) or die ("Cannot connect to host");
  ftp_login($conn_id, $usr, $pwd) or die("Cannot login");

// turn on passive mode transfers (some servers need this)
// ftp_pasv ($conn_id, true);

  $upload = ftp_put($conn_id, $file[0], $file[1], FTP_ASCII);

  print (!$upload) ? die('Cannot upload') : 'Upload complete';
  print "\n";

 

The permissions to the file is 0644, if I change it to 0777 ftp_put complains and says the file is not found.

 

How can I ftp this file? What is going on?

 

Thanks,

Chris

Link to comment
https://forums.phpfreaks.com/topic/233564-ftp_put-permission-denied-problem/
Share on other sites

couldn't find a fix for this and it seems as though nobody else knows. I just used curl to download the files instead of uploading them from one server to the other server. here's my code if anybody else has this problem.

$newFile = "fileNameNew.php";

echo "<br>Starting<br>Target_url: http://url.com<br><br>";


// make the cURL request to $package
  $ch = curl_init();
  $fp = fopen("$newFile", "w");
  curl_setopt($ch, CURLOPT_USERAGENT,'Googlebot/2.1 (http://www.googlebot.com/bot.html)');
  curl_setopt($ch, CURLOPT_URL,"http://url.com");
  curl_setopt($ch, CURLOPT_FAILONERROR, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  curl_setopt($ch, CURLOPT_FILE, $fp);

  $page = curl_exec($ch);


  if (!$page) {
    echo "<br />cURL error number:" .curl_errno($ch);
    echo "<br />cURL error:" . curl_error($ch);
    die();
  }
  curl_close($ch);

  echo "<br>Downloaded file: $newFile";
  echo "<br>Saved as file: $newFile";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.