Jump to content

CHMOD


tcorbeil

Recommended Posts

Can't get this work guys...  can you's help?

 

!ftp_chmod($connection, 777, $Subpage);

 

$Subpage is the variable that holds the directory name..

 

I keep getting this error:

 

Fatal error: Call to undefined function: ftp_chmod() in .....

 

Thanks in advance..

 

T.

 

Link to comment
Share on other sites

Hey fert..

 

you lost me..  can you clarify?

 

I have the following 3 lines in my script to which the 2 first ones work perfectly..

 

!ftp_chdir($connection, $currentdir);

!ftp_mkdir($connection,$Subpage) ;

!ftp_chmod($connection, 777, $Subpage);

 

So basically, go to a specific directory, make a new directory and then make the new directory CHMOD 777.

 

Any further input would be appreciated..

T.

Link to comment
Share on other sites

Ok, sorry for the bother..  I got it...

 

add this to the beginning of the script to create function..

 

if (!function_exists('ftp_chmod')) {

  function ftp_chmod($ftp_stream, $mode, $filename)

  {

      return ftp_site($ftp_stream, sprintf('CHMOD %o %s', $mode, $filename));

  }

}

 

Link to comment
Share on other sites

<?php

$file = 'public_html/index.php';

 

// set up basic connection

$conn_id = ftp_connect($ftp_server);

 

// login with username and password

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

 

// try to chmod $file to 644

if (ftp_chmod($conn_id, 0644, $file) !== false) {

echo "$file chmoded successfully to 644\n";

} else {

echo "could not chmod $file\n";

}

 

// close the connection

ftp_close($conn_id);

?>

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.