NYCPHP Meetup

NYPHP.org

[nycphp-talk] mkdir failed

Hans Zaunere zaunere at yahoo.com
Sat Sep 28 16:20:18 EDT 2002


--- Phil Powell <soazine at erols.com> wrote:
> Ok, I am stuck.  I am trying to create a folder in the same directory
> as process.php and then use
> move_uploaded_file($FILES['myImage]['tmp_name']) and it constantly
> fails:
> 
> mkdir() failed (Permission denied) 

There could be a couple reasons for this.  However, most likely, is
that the Apache daemon doesn't have permission to write in
/users/ppowell/web/my/images.  I'm assuming this is a shared
environment, in which case it's rare (and good) that a daemon has write
permissions in a user's directory.  Depending on the configuration,
you'll need to chmod g+rwx /users/ppowell/web/my or chmod o+rwx
/users/ppowell/web/my (hark!).  But it's probably better to make the
directory beforehand, and then set it aside with write permissions,
ditching the mkdir() from PHP.

But be weary, because anyone using the same daemon will have write
permissions there as well (hopefully, however, the PHP is setup with
safe mode properly to surpress any potential issues).  I haven't been
in a lot of shared environments so there may be a trick to this that is
safe[r], but this is the only way around it AFAIK.  And this is why
MySQL has become popular for storing files, ahem.

Hans



> 
> Here is my code:
> 
> <?
>   $willChangeLayout = 1; $isEmptyLayoutValues = 1;
> 
>   foreach ($_POST as $key => $val) {
>    if (strcmp($key, "isDefaultLayout") == 0) $willChangeLayout = 0;
>    if (!empty($_POST[$key])) $isEmptyLayoutValues = 0;
>    ${"$key"} = $val;   
>   }
> 
>   // SERVER-SIDE VALIDATION
>   if ($willChangeLayout && $isEmptyLayoutValues)
>    header("Location: " . $refURL . "?errorMsg=" . urlencode("Please
> fill out all required fields"));
> 
>   // FILE UPLOAD HANDLING
> 
>   $attempt = mkdir("/users/ppowell/web/my/images", 0655);
> 
>   if (is_uploaded_file($_FILES['myImage']['tmp_name'])) 
>    move_uploaded_file($_FILES['myImage']['tmp_name'],
> "/users/ppowell/web/my/images/" . $_FILES['myImage']['name']);
> 
>    
> ?>
> 
> Please someone tell me what I'm doing wrong :(
> 
> Thanx
> Phil
> 
> 
> 
> --- Unsubscribe at http://nyphp.org/list ---
> 
> 


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com



More information about the talk mailing list