Jump to content

Archived

This topic is now archived and is closed to further replies.

Twentyoneth

mkdir problems

Recommended Posts

Ok, I have a dir called "stylists" which will contain stylists names as dir's. Like so:

stylists >> thomas
stylists >> stacy
stylists >> albert

ect...

I have this code for adding a profile, which includes making a directory if one by that name doesnt exist.

[code]<?php
$user = $HTTP_COOKIE_VARS['UserName'];

if($user == "******") {

if($_POST['Add/Update']) {

   $euser = $_POST['euser'];
   $ppic = $HTTP_POST_FILES['ppic'];
   $ebody = stripslashes($_POST['ebody']);
   $before = $_POST['before'];
   $after = $_POST['after'];
   $title = stripslashes($_POST['bnatitle']);

   $makedir = ("stylists/" . $euser);
   $writedir = ("stylists/" . $euser . "/");

   if($euser !== null) {

      if(!is_dir($makedir)) {

         mkdir($makedir, 0777);

        }

     }

  }
  }

?>[/code]

The problem I am having, is that once I make the directory, I cannot use it for anything, I cannot even upload files into that directory via FTP. This script will aslo be uploading a user pic, a bio, and a short summary, along with some before and after photo's. So actually using this dir is vital. What the problem with my script? Permissions? How do I fix it?

[NOTE: This is only up until the make directory part of the code, which is seemingly where my problem is.]

Share this post


Link to post
Share on other sites
take a look at this:
[a href=\"http://uk.php.net/manual/en/function.umask.php\" target=\"_blank\"]umask[/a]

Share this post


Link to post
Share on other sites
[!--quoteo(post=368224:date=Apr 24 2006, 08:24 PM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Apr 24 2006, 08:24 PM) [snapback]368224[/snapback][/div][div class=\'quotemain\'][!--quotec--]
take a look at this:
[a href=\"http://uk.php.net/manual/en/function.umask.php\" target=\"_blank\"]umask[/a]
[/quote]

I tued using the "umask" function with no luck, I'm not 100% sure on how to use it properly, so I am providing my full code for further help.

[code]<?php
$user = $HTTP_COOKIE_VARS['UserName'];

if($user == "******") {

if($_POST['Add/Update']) {

   $euser = $_POST['euser'];
   $ppic = $HTTP_POST_FILES['ppic'];
   $ebody = stripslashes($_POST['ebody']);
   $before = $HTTP_POST_FILES['before'];
   $after = $HTTP_POST_FILES['after'];
   $title = stripslashes($_POST['bnatitle']);

   $makedir = ("stylists/" . $euser);
   $writedir = ("stylists/" . $euser . "/");

   if($euser !== null) {
      if(!is_dir($makedir)) {
         mkdir($makedir);
        }
      if($HTTP_POST_FILES['ppic'] == null) {
        } else {
         $newname = ($writedir . "ppic.jpg");
         $uploadfile = ($writedir . basename($HTTP_POST_FILES['ppic']['name']));
         echo ($newname['dirname'] . "<br>");
         echo ($newname['basename'] . "<br>");
         echo ($newname['extension'] . "<br>");
         if (m ove_uploaded_file($HTTP_POST_FILES['ppic']['tmp_name'], $uploadfile)) {
             r ename("$uploadfile", "$newname");
             echo ("File is valid, and was successfully uploaded.<br><br>");
            } else {
             echo "Could not upload file.";
            }
        }
      if($ebody == null) {
        } else {
         $fto = ($writedir . "profile.php");
         $file = f open($fto, 'w') or die("Cannot open file to write.");
         f write($file, $ebody);
         echo "File for ebody written.";
         f close($file);
        }
      if($before != null && $after != null && $title != null) {
        }
     } else {
      echo "You must enter the name of the profile you wish to edit.";
     }

  } else {

   echo "
<table border='0' width='100%'><tr><td vAlign='top' align='center'>

   <form action='?func=editprofile' enctype='multipart/form-data' method='POST'>
    <input type='hidden' name='MAX_FILE_SIZE' value='9000000000000' />

      <table border='0'>
      <tr><td vAlign='top' align='left'>
         Enter User To Edit/Create:
      </td><td vAlign='top' align='left'>
         <input type='text' name='euser' />
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Occupation:
      </td><td Valign='top' align='left'>
         <select name='occ'>
            <option>
               Select--
            </option>
            <option>
               Stylists
            </option>
            <option>
               Massage Therapist
            </option>
            <option>
               Electrolysist
            </option>
            <option>
               Manicure/Pedicurist
            </option>
         </select>
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Add/Change Profile Picture:
      </td><td vAlign='top' align='left'>
         <input type='file' name='ppic' />
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Enter Summary Text:
      </td>
      <td vAlign='top' align='left'>
      <textarea rows='5' cols='24' name='esum'></textarea>
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Enter Bio Text:
      </td>
      <td vAlign='top' align='left'>
      <textarea rows='5' cols='24' name='ebody'></textarea>
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Before:
      </td><td vAlign='top' align='left'>
         <input type='file' name='before' />
      </td></tr>
      <tr><td vAlign='top' align='left'>
         After:
      </td><td vAlign='top' align='left'>
         <input type='file' name='after' />
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Title for Pictures:
      </td><td vAlign='top' align='left'>
         <input type='text' name='bnatitle' />
      </td></tr>
      <tr><td></td>
      <td vAlign='top' align='right'>
         <input type='submit' value='Add/Update' name='Add/Update' />
      </td></tr>
      </table>

</td></tr></table>

</form>";

  }

} else {

echo "You do not have permission to view this page.";

}

?>[/code]

[NOTE: I put some spaces in some of the functions to allow the post. ]

Share this post


Link to post
Share on other sites
[!--quoteo(post=368240:date=Apr 24 2006, 09:08 PM:name=KrisNz)--][div class=\'quotetop\']QUOTE(KrisNz @ Apr 24 2006, 09:08 PM) [snapback]368240[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Are you on a windows OS?
[/quote]

Windows XP SP2

Share this post


Link to post
Share on other sites
Current code:

[code]<?php
$user = $HTTP_COOKIE_VARS['UserName'];

if($user == "******") {

if($_POST['Add/Update']) {

   $euser = $_POST['euser'];
   $ppic = $HTTP_POST_FILES['ppic'];
   $sum = stripslashes($_POST['esum']);
   $ebody = stripslashes($_POST['ebody']);
   $before = $HTTP_POST_FILES['before'];
   $after = $HTTP_POST_FILES['after'];
   $title = stripslashes($_POST['bnatitle']);
   $occ = $_POST['occ'];

   $makedir = ("stylists/$euser");
   $writedir = ("stylists/$euser/");

   if($euser !== null) {
      if(!is_dir($writedir)) {
         mkdir($makedir, 0777);
        }
      if($occ !== null) {
         $occfile = ($writedir . "occupation.php");
         $occwrite = f open($occfile, 'w')or die("Cannot write '$occ' to $occfile.");
         f write($occwrite, $occ);
         f close($occwrite);
        }
      if($HTTP_POST_FILES['ppic'] == null) {
        } else {
         $newname = ($writedir . "ppic.jpg");
         $uploadfile = ($writedir . basename($HTTP_POST_FILES['ppic']['name']));
         if (move_uploaded_file($HTTP_POST_FILES['ppic']['tmp_name'], $uploadfile)) {
             rename("$uploadfile", "$newname");
             echo ("File is valid, and was successfully uploaded.<br><br>");
            } else {
             echo "Could not upload file.";
            }
        }
      if($esum !== null) {
         $esumfile = ($writedir . "shortie.php");
         $esumwrite = f open($esumfile, 'w') or die("Cannot open $esumfile.");
         f write($esumwrite, $esum);
         f close($esumwrite);
        }
      if($ebody !== null) {
         $fto = ($writedir . "bio.php");
         $file = f open($fto, 'w') or die("Cannot write to $fto.");
         f write($file, $ebody);
         echo "File for ebody written.";
         f close($file);
        }
      if($before !== null && $after !== null && $title !== null) {
        }
     } else {
      echo "You must enter the name of the profile you wish to edit.";
     }

  } else {

   echo "
<table border='0' width='100%'><tr><td vAlign='top' align='center'>

   <form action='?func=editprofile'enctype='multipart/form-data' method='POST'>
    <input type='hidden' name='MAX_FILE_SIZE' value='9000000000000' />

      <table border='0'>
      <tr><td vAlign='top' align='left'>
         Enter User To Edit/Create:
      </td><td vAlign='top' align='left'>
         <input type='text' name='euser' />
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Occupation:
      </td><td Valign='top' align='left'>
         <select name='occ'>
            <option>
               Select--
            </option>
            <option>
               Stylists
            </option>
            <option>
               Massage Therapist
            </option>
            <option>
               Electrolysist
            </option>
            <option>
               Manicure/Pedicurist
            </option>
         </select>
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Add/Change Profile Picture:
      </td><td vAlign='top' align='left'>
         <input type='file' name='ppic' />
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Enter Summary Text:
      </td>
      <td vAlign='top' align='left'>
      <textarea rows='5' cols='24' name='esum'></textarea>
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Enter Bio Text:
      </td>
      <td vAlign='top' align='left'>
      <textarea rows='5' cols='24' name='ebody'></textarea>
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Before:
      </td><td vAlign='top' align='left'>
         <input type='file' name='before' />
      </td></tr>
      <tr><td vAlign='top' align='left'>
         After:
      </td><td vAlign='top' align='left'>
         <input type='file' name='after' />
      </td></tr>
      <tr><td vAlign='top' align='left'>
         Title for Pictures:
      </td><td vAlign='top' align='left'>
         <input type='text' name='bnatitle' />
      </td></tr>
      <tr><td></td>
      <td vAlign='top' align='right'>
         <input type='submit' value='Add/Update' name='Add/Update' />
      </td></tr>
      </table>

</td></tr></table>

</form>";

  }

} else {

echo "You do not have permission to view this page.";

}

?>[/code]

Some changes made.....The permissions are the same as other folders I am allowed to upload and create files in, but when I try, it wont let me create or upload, what do I need to do to fix this, anyone?

Share this post


Link to post
Share on other sites
Anyone?

The problem is getting very sticky for me, I am a newb, and I have written this code, it's the first time I have used the mkdir() function, and its confusing me, it sets permissions as 0777, in my FTP file manager it shows that it has the same permissions as other directories that I created using my FTP file manager, but it wont let me do anything with the directory, except delete it, through the FTP file manager, how do I make it useable?

Share this post


Link to post
Share on other sites

×

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.