There it will explain exactly what I'm trying to do... But for now, I'll give you the 411. I've erased all coding and I'm starting from scratch just for testing. So, basically, all that coding you saw on the previous page is worthless for now.
specifies the server path. You can look into this in more detail by using your ftp client, which may well display the server path as you browse.
Finally:
If you read the last post of the thread I posted... the CHMOD function doesn't work on all servers sometimes or something. So, basically, I can't do that. I meant the FTP connection example they have at the bottom of the page was what I didn't understand. I understood the CHMOD command.
I don't think adding in an FTP connection is the way to go. You're going to be passing your username / password in clear text over the internet on every page request. I'd shy away from that approach if possible.
I think the relevant information from php.net is this ...
Quote:
Note: The current user is the user under which PHP runs. It is probably not the same user you use for normal shell or FTP access. The mode can be changed only by user who owns the file on most systems.
Note: This function will not work on remote files as the file to be examined must be accessible via the servers filesystem.
Note: When safe mode is enabled, PHP checks whether the files or directories you are about to operate on have the same UID (owner) as the script that is being executed. In addition, you cannot set the SUID, SGID and sticky bits.
My guess is your server has php safe_mode enabled and the file you are trying to chmod does not have the same owner as required to chmod the file.
There is another way to CHMOD and it works on different servers. I've had the problem where chmod() didnt work but this did.
Try this
PHP Code:
//path to filename is relative to the current FTP directory so if you want to modify a file in the root called 'filename.txt' use this:
$conn_id = ftp_connect('SERVER');
$login_result = ftp_login($conn_id,'USERNAME','PASSWORD');
ftp_site($conn_id,"CHMOD 777 filename.txt");
//if the file is in a directory called directory you can use
$conn_id = ftp_connect('SERVER');
$login_result = ftp_login($conn_id,'USERNAME','PASSWORD');
ftp_site($conn_id,"CHMOD 777 directory/filename.txt");
<?
if(!isset($_POST['submit'])) {
echo "Form requiring user name and password.";
} else {
The code you showed me except with a $user_name = $_POST['variable']; etc.
}
?>
It'd still work if I did this, right? They'd also have to type in the path... So could it be "CHMOD 777 $path"? Wouldn't it CHMOD the directory?
Well you have to change the username and password etc because I'm sure your users don't have them set as USERNAME and PASSWORD They can come from wherever you want, post variables, defines, hard coded whatever.
You can use the post submit thing, the only thing I showed was how to CHMOD a file. The username and password need to be the ftp username and password and the server has to be correct. Also, you will need to get the path right, and I don't know if alot of users (without much knowledge) would know how to fill that in.