dcgamers Posted January 11, 2007 Share Posted January 11, 2007 I am tring to chmod a file using the following code:[code]<?$imm = "$_GET[url]";chmod("$imm", 755);?>[/code]and I get the following:Warning: chmod() [function.chmod]: Operation not permitted in /home/****/public_html/****.php on line 3Please help! Quote Link to comment Share on other sites More sharing options...
icicleman Posted January 11, 2007 Share Posted January 11, 2007 Im not sure but are you logged in as an adminastrator? Quote Link to comment Share on other sites More sharing options...
dcgamers Posted January 11, 2007 Author Share Posted January 11, 2007 how would I know? Quote Link to comment Share on other sites More sharing options...
DarkendSoul Posted January 11, 2007 Share Posted January 11, 2007 Well first, what are you setting $_GET[url] do note that this would be ****.php?url=[b]whatever.end[/b] Not the actual url.A cleaner way to set $imm would be like$imm = $_GET['url'];then usechmod($imm, 755);It wont change the function but clean code is good code. Quote Link to comment Share on other sites More sharing options...
dcgamers Posted January 11, 2007 Author Share Posted January 11, 2007 ok but I still have a problem that no one seems to help me with Quote Link to comment Share on other sites More sharing options...
icicleman Posted January 11, 2007 Share Posted January 11, 2007 What I was trying to say is if you are not logged in as an adminastrator then you cant change permmissions Quote Link to comment Share on other sites More sharing options...
DarkendSoul Posted January 11, 2007 Share Posted January 11, 2007 If the file your trying to chmod on isn't in the same folder you may get this error. Also... are you running on windows?Also maybe try...[code]<?php$imm = $_GET['url'];if (chmod($imm, 755)) echo "I don't care what the error message says, I did the job.";else echo "About what you told me to do... yeah... slight problem there.";?>[/code] Quote Link to comment Share on other sites More sharing options...
dcgamers Posted January 11, 2007 Author Share Posted January 11, 2007 very funny. My server is a Linux. I tested the function on a file in the same folder and it got that error and not being in the same directory has nothing to do with this error. Quote Link to comment Share on other sites More sharing options...
btherl Posted January 11, 2007 Share Posted January 11, 2007 Try[code=php:0]<?$imm = "$_GET[url]";$fstats = fstat($imm);if (!$fstats) { die("Couldn't fstat() $imm");}$file_uid = $fstats['uid'];$my_uid = getmyuid();print "File is owned by $file_uid, my uid is $my_uid\n";?>[/code]If the fstat() fails, then you may be looking in the wrong directory, or you may not have permission to read the directory the file is in. If the uids don't match, then that is why you cannot change permissions on that file. Quote Link to comment Share on other sites More sharing options...
dcgamers Posted January 11, 2007 Author Share Posted January 11, 2007 uggg.....right directory:Warning: fstat(): supplied argument is not a valid stream resource in /home/****/public_html/****.php on line 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.