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
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";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.