TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   mkdir - need help (http://www.talkphp.com/absolute-beginners/3256-mkdir-need-help.html)

sarmenhb 08-18-2008 06:03 PM

mkdir - need help
 
im trying to make this code work

Code:

$userid =  $_COOKIE['usersid'];
$foldername = "/upload/".$userid;       
mkdir($foldername) or die("error");

so a directory will be created inside the upload folder by the name that is stored in the cookie.

this is the error im getting

Code:

Warning: mkdir() [function.mkdir]: Permission denied in /home/gothostin/www/www/checklist/intro.php on line 8
error

if this is a permission problem, how do i set chmod to 777 ?

the weird thing is when i tried doing this

mkdir(testfolder); it worked and the folder was careted. but when i try doing that it doesnt work..

any ideas?

xenon 08-18-2008 07:07 PM

Quote:

Originally Posted by sarmenhb
if this is a permission problem, how do i set chmod to 777 ?

Via FTP or SSH.

Quote:

Originally Posted by sarmenhb
mkdir(testfolder); it worked and the folder was careted. but when i try doing that it doesnt work..

It worked probably because the directory in which you are executing the file is not /upload/.

delayedinsanity 08-18-2008 08:06 PM

Just a note, 0755 should be good enough for anything you need to do - setting any permissions to 0777 is dangerous, and should be avoided if at all possible.

Tutorial for chmod
chmod - Wikipedia, the free encyclopedia

-m

tony 08-18-2008 08:40 PM

you could use the exec() function to execute a command in the computer and use the chmod command in it.

Village Idiot 08-18-2008 09:25 PM

Some hosts don't let you create directories from the application user for security/speed reason (they would have to create a new user for every account). This is one of the many reasons I do not like shared hosting.

Kalle 08-18-2008 09:34 PM

Quote:

Originally Posted by tony (Post 17861)
you could use the exec() function to execute a command in the computer and use the chmod command in it.

Or use the builtin chmod() function:
PHP Code:

chmod('/kalle/desktop/'0755); 

More notes on the function is ofcourse available on its documentation: PHP: chmod - Manual

tony 08-18-2008 09:41 PM

Quote:

Originally Posted by Kalle (Post 17864)
Or use the builtin chmod() function:
PHP Code:

chmod('/kalle/desktop/'0755); 

More notes on the function is ofcourse available on its documentation: PHP: chmod - Manual

yeah much better, I overlooked that one.


All times are GMT. The time now is 07:37 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0