chmod() problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

chmod() problems

Post 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!
thegreatone2176
Forum Contributor
Posts: 102
Joined: Sun Jul 11, 2004 1:27 pm

Post by thegreatone2176 »

add a " after ['name'] in the chmod line
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

thegreatone2176 wrote:add a " after ['name'] in the chmod line
That is not the problem, he escaped the double quote.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

maybe something goofy with umask() ?
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

How can umask be used? What file is it targeting, it just has one parameter...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

from what I remember, umask() set a unilateral mask for all permissions type stuffs.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Hmm, alright, thanks.
Post Reply