473,382 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to change file permission of multiple files at once using chmod?

142 100+
Hi,

I am trying now for the last 2 weeks to get a $!*@ script to change all my files under one folder to 644.

Can someone please help me or just give me a script you have cause I am now fed up with this stuff not wanting to work.

Thank-you

[PHP]
$file = all my files in my images folder or this directory


$old = umask(0);
chmod("$file", 0644);
umask($old);

// Checking
if ($old != umask()) {
die('An error occured while changing back the umask');
}
[/PHP]
Jul 25 '07 #1
2 5270
kovik
1,044 Expert 1GB
Look into the directory functions.
Jul 26 '07 #2
psylem
1
I was having the same issue. I don't know how you do it with PHP, but this command worked for me...

find /var/www/html/*/ -type d -exec chmod 755 {}/*.php \;

It changes the permissions of all php files in the html directory. You may want to also change the permissions on the directories them selves as well, in which case run this one too...

find /var/www/html/*/ -type d -exec chmod 755 {} \;
Sep 2 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: kafooey | last post by:
Hi all, I've been digging around on the newsgroups and the web for a possible answer for this problem, but have so far come up with nothing so thought I would ask here... I have the following...
5
by: Phil Powell | last post by:
print_r(is_file("$logPath/$logFileName")); // RETURNS 1 unlink("$logPath/$logFileName"); // RETURNS WARNING: PERMISSION DENIED This code should tell me that the file located at...
6
by: jonathanmcdougall | last post by:
I have read many posts on this subject and found no satisfying answer. I am creating a file on the server via a PHP script. The file is created using GD (imagejpeg()), though I don't think it is...
4
by: Simon Niederberger | last post by:
Hi all I need to write a script which overwrites certain .php files in the current directory. Running as www user, I get a Permission denied on fopen. Obviously, I could CHMOD all files to allow...
1
nallinattu
by: nallinattu | last post by:
How do I change CHMOD of a folder / file through a PHP script ? (I do not want it done by an FTP client ) Many a times I have had problem to change CHMOD of a file but when I empty the folder and...
7
by: luigi7up | last post by:
Weird problem I have, really :) I wrote a script that uploads files to /user_upload/ directory. On localhost version of my site everything works just fine. I mean files are uploaded well. With...
4
by: Tony B | last post by:
I've moved an existing site (which I didn't write) from a apache/php/mysql host under windows to a linux apache/php/mysql host. I've sorted out most problems except one. There is an upload...
30
by: Adam Baker | last post by:
Hello, I'm writing a site where a handful of people will be able to edit the content using PHP scripts (FCKeditor). The content is stored as individual files in a directory. I'd like to validate...
3
by: brook | last post by:
hey all - i´m new to php and having trouble writing a simple code which should create a file. here is the most simplified version: <?php $content = "my content"; $path = "test.txt";...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.