tags:

views:

23

answers:

3

I took an opportunity to batch optimise a folder of images from my site, of course i forgot the new images would not have the permissions 777.

Given the wiki-type nature of my site i need users to be able upload/replace the images!

is there anyway i can change the permissions of the whole folder's images either with a php script or ftp program?

A: 

How about chmod 777 *?

If you don't have access to the command-line, you should be able to use one of the Program execution functions such as exec

Bobby Jack
wow that looks a bit hardcore, i thought maybe there'd be a recursive php chmod flag or something?
Haroldo
I'm not sure there's a single PHP function to do this - chmod() doesn't seem to take a wildcard. You could call chmod() in a loop over all filenames, though.
Bobby Jack
+1  A: 

Use chmod() function, documentation you can find at http://pl2.php.net/manual/en/function.chmod.php

if ($handle = opendir('/path/to/files')) {

    /* This is the correct way to loop over the directory. */
    while (false !== ($file = readdir($handle))) {
        chmod($file, 0777);
    }

    closedir($handle);
}
Svisstack
isn't this just for a single file?
Haroldo
@Haroldo - it is. If, for some reason, you can't use the command-line program, you could loop over all files in the directory and call chmod(), passing each filename
Bobby Jack
you can `readdir` to use this in while.
Svisstack
@bobby ah ok, this is what i though just hoped there might be a neater solution
Haroldo
Probably want to check for "." and ".."
Bobby Jack
A: 

In filezilla: Select all -> Right click -> File permissions (at the bottom)

with php: http://www.php.net/manual/en/function.chmod.php

Arnar Yngvason
nothing like right clicking on something for easiness! thanks Arnar
Haroldo