directory permission

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
dibyendra
Forum Newbie
Posts: 20
Joined: Tue Aug 12, 2003 2:26 am
Location: Nepal

directory permission

Post by dibyendra »

hello phpdevs,
I have small upload script which uploads the file in the upload directory.

Code: Select all

<?php
if(isset($HTTP_POST_VARS["Submit"]))
{
	if ($fupload_size > 307200)//if greater than 300KB 
	{
		header("Location:error.php");
		exit;
	}	
              else
	{
	if(!copy ($fupload, "upload/$fupload_name"))
	     echo "failed to copy the image";
	else
	     header("Location:thanks.php");
	}
}	
?>
when i execute the script in locally it uploads the file but when I execute it in online it displays the error :
failed to create stream: Permission denied
how can I change the directory read/write by php chmod?
please Help.
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post by thomas777neo »

This should work:

Code: Select all

chmod ("/somedir/somefile", 0755);  // octal; correct value of mode

This is for a linux based os.

The only chmods allowed are the 775 and 666 mod. 775 for non-writeable and 666 for writeable. The only thing is that the usergroups don't work.
Note: the 0 at the start doesn't work with windows. use only the decimal kind.

Hope this helped
Post Reply