Jump to content

Recommended Posts

Is there a way to change file permissions to a file that is not created by php, but rather one that I uploaded myself?

 

I'm getting this error:

Warning: file_put_contents(head.tmpl) [function.file-put-contents]: failed to open stream: Permission denied in /path/functions.php on line 211

 

Maybe something like so:

<?php
system("chmod -R 777   \"/head.tmpl\" ");
?>

 

I don't know? Not sure? Any ideas??

Link to comment
https://forums.phpfreaks.com/topic/183885-changing-file-permissions/
Share on other sites

I have tried this:

<?php
chmod("head.tmpl", 0777);
?>

 

But I get this error:

Warning: chmod() [function.chmod]: Operation not permitted in /path/functions.php on line 211

 

Does the directory that the file is in need to be writable as well or something?

If you are uploading the file using FTP or your hosting control panel, the owner of the file is the user that the FTP server or the control panel us running under. The user that the web server/Php is running under cannot alter the permissions (that would kind of defeat the purpose of having permissions.)

 

You need to change the permissions on the folder and/or file using the same method that you used to upload it.

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.