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! Link to comment https://forums.phpfreaks.com/topic/33671-chmod-error/ 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? Link to comment https://forums.phpfreaks.com/topic/33671-chmod-error/#findComment-157787 Share on other sites More sharing options...
dcgamers Posted January 11, 2007 Author Share Posted January 11, 2007 how would I know? Link to comment https://forums.phpfreaks.com/topic/33671-chmod-error/#findComment-157790 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. Link to comment https://forums.phpfreaks.com/topic/33671-chmod-error/#findComment-157797 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 Link to comment https://forums.phpfreaks.com/topic/33671-chmod-error/#findComment-157800 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 Link to comment https://forums.phpfreaks.com/topic/33671-chmod-error/#findComment-157810 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] Link to comment https://forums.phpfreaks.com/topic/33671-chmod-error/#findComment-157818 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. Link to comment https://forums.phpfreaks.com/topic/33671-chmod-error/#findComment-157831 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. Link to comment https://forums.phpfreaks.com/topic/33671-chmod-error/#findComment-157983 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 Link to comment https://forums.phpfreaks.com/topic/33671-chmod-error/#findComment-158531 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.