Page 1 of 1

chmod() problems

Posted: Sun Feb 06, 2005 12:13 pm
by evilmonkey
Hi! I have a code that uploads a picture to the server, and then I need to chmod it to 777. It is uploaded at 644 by default. The problem is, when I run the chmod() command, the file permission becomes 1411, which is just nonsense. I'm guessing the last digit is ignored, but anyway. What can I do? Below is the upload code:
<?php
//...
if ($_FILES['pic'.$i]['name']!=""){ //if there was input
$info = @getimagesize($_FILES['pic'.$i]['tmp_name']);
if ($info[2]==2) {
if (move_uploaded_file($_FILES['pic'.$i]['tmp_name'], "../pics/".$album_name."/".$_FILES['pic'.$i]['name'])){
chmod("../pics/".$album_name."/".$_FILES['pic'.$i]['name'], 0777);
mysql_query("INSERT INTO `pictures` (`url`, `album`, `date`) VALUES ('/pics/".$album_name."/".$_FILES['pic'.$i]['name']."', '".$album."',".$date.")", $db) or die (mysql_error());
}
else { die("Cannot upload file"); }

}
else{
die ("ALL PICS MUST BE .JPG or .JPEG! Please go back and fix it");
}
}
//...
?>
Sorry, I really hate the output of the

Code: Select all

tags.

Thanks!

Posted: Sun Feb 06, 2005 4:24 pm
by thegreatone2176
add a " after ['name'] in the chmod line

Posted: Sun Feb 06, 2005 4:30 pm
by John Cartwright
thegreatone2176 wrote:add a " after ['name'] in the chmod line
That is not the problem, he escaped the double quote.

Posted: Sun Feb 06, 2005 7:37 pm
by evilmonkey
Phenom wrote:
thegreatone2176 wrote:add a " after ['name'] in the chmod line
That is not the problem, he escaped the double quote.
Yes, I would've noticed that if that was the error because of the syntx highlighting. Can anyone tell me what I can do?

Thanks!

Posted: Sun Feb 06, 2005 7:52 pm
by feyd
maybe something goofy with umask() ?

Posted: Mon Feb 07, 2005 6:17 pm
by evilmonkey
How can umask be used? What file is it targeting, it just has one parameter...

Posted: Mon Feb 07, 2005 6:34 pm
by feyd
from what I remember, umask() set a unilateral mask for all permissions type stuffs.

Posted: Tue Feb 08, 2005 6:03 pm
by evilmonkey
Hmm, alright, thanks.