I had a php server and a directory named "images" in it. I need to change the folder's permission to 0777 via php script....

I had the code like this

chmod('/images',0777);

But It will give the following results...

Warning: chmod() [function.chmod]: No such file or directory in /home/keralaba/public_html/bkp3/new.php on line 2

Please Help me...
Thanks
Rajeesh

Recommended Answers

All 7 Replies

thats a nightmare,
read write execute to everyone,
Malicious persons can add files to your folder, and shut down or takeover your site
not a good idea
permissions to the script that writes to the folder, according to the use to which you are going to put your images.
check what your scripts need, and allocate those rights to the user that the script is running as, not to everyone, and not from a script,

I just need to do a image upload script in php. For that I need to change the permission of that folder only at the time of upload processing... After that I need to change it into 0775 ....
Please Help me

no you dont,
the script doing the upload runs from your server, not the user

The error is due to the "/" before "images", which causes PHP to look in another directory. You should use:

chmod("./images",0755);

Also, almostbob is correct, 755 is sufficient to run your image upload script (unless you're using some non-standard means of transferring the image, in which case you may want to try a more common approach).

How can I upload image in 0755 mode... ??? Please Help me ...

How can I upload image in 0755 mode... ??? Please Help me ...

It's actually quite easy. A quick Google search gave me this:
http://www.jswick.com/personal/blogComments.php?blogID=17

You could literally copy and paste that script. Note his use of CHMOD is incorrect - it should be:

CHMOD($file, 0644);

How can I upload image in 0755 mode... ??? Please Help me ...

because the script should be running on the server as owner of the file, it is the 7 in 755, it has all rights

if the hosting is set up, nonstandard-ly, then your script should work with chmod 775, running as server group
there should be no need to expose your site to, persons-of-evil-intent, chmod 777
Picture a number of images being uploaded through your script, ~2.5 seconds is all I need
while the transfer is proceeding
person-of-evil-intent drag-n-drops a bunch of php scripts on the folder.
the upload script finishes
the files are chmodded to 755,
but now evil-intent has access to your server through the scripts they added
I can write a bot to do it, (and host it from your web page to infect others, if you leave me a hole) so person-of-evil-intent can,

first digit owner 7 read write execute, // this is where your script should run
second digit group 7 read write execute // this may be where your script is running
third digit other 5 read execute // this is all us schleps in the outer world, we are 1% dangerous & malicious, 99% ok.
but it only takes 1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.