Jump to content

creating directory


tryingtolearn

Recommended Posts

Hi all -
I have 2 questions on creating directories.

First - I am using this code to create the directory using the user ID as a subfolder.
This finally got worked out so the permissions were set right and it works.

[code]$oldumask = umask(0);
mkdir("images/$user_id/", 0777);
umask($oldumask);[/code]

The first time the user uploads a photo it works fine
But the next photo uploaded is triggering errors since the directory already exists.

I tried adding if else statements but it seems to ignore that.
That leads to the second question,
- when creating the directory it is listed as apache as the owner.
Would this affect any of the error messages (I dont think so because it is all working fine)

So how can write it to only create the directory if it doesnt exist.
This was the last attempt the didnt do anything.
[code]if (is_dir('images/$user_id/')) {
}
else{
$oldumask = umask(0);
mkdir("images/$user_id/", 0777);
umask($oldumask);
}[/code]
Link to comment
Share on other sites

Thanks thorpe,
Tried that way also - I redid it and by copying and pasting your code just to make sure.

I still get this error -

mkdir(images/5): File exists
Date/Time: 6-13-2006 18:04:10

Well Im saying error - but everything is uploading so is it just a warning or is it an error?
Is there a difference??

Just wondering.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.