Jump to content

Directory created using mkdir() unusable...


eppievojt

Recommended Posts

I created a directory using mkdir, setting permissions to 0777 - directory shows up right where it is supposed to.  Unfortunately, whenever I try to run my upload script to this directory, it kicks out.  Same thing if I try to create a simple txt file.  It won't work.  There's not a problem with the scripts, because if I change the directory to load to, they work fine.  Why are the directories I'm creating using PHP unusable?  Any ideas?

Link to comment
Share on other sites

The directory it's trying to upload to is created by Apache using mkdir() - it's part of the same script.  Here's some code for a most simple test to see if the directory is working properly:

 

<?php

$targetdir="/var/www/vhosts/domain.net/httpdocs/mydir/";
$newdir="103457/";
$targetdir=$targetdir.$newdir;

if(!(file_exists($targetdir))){
  mkdir($targetdir,0777,TRUE);
}

      $test=$targetdir."test.txt";

      $fr = fopen($test,'w');
      if(!$fr) {
         echo "Could not create the test file!";
         exit;
      }
      fputs($fr, "text");
      fclose($fr);

?>

 

mydir is NOT owned by Apache, but there's no problem in creating the directory.  The problem is once the directory is made, nothing writes to it.

 

I use the exact same code on another domain with the same folder structure and there are no problems, which is what is very frustrating.  This was supposed to be an easy port over from a test server.  Thanks for any assistance you can render.

Link to comment
Share on other sites

Does this server have the same platform as the test server? What about OS?

Is your error reporting cranked up for this script? What errors are you getting?

Since you're using the full path, there could be underlying permission issues--a missing "x". Have you tried to chdir to that directory, then create it relatively?

Link to comment
Share on other sites

Does this server have the same platform as the test server? What about OS?

Is your error reporting cranked up for this script? What errors are you getting?

Since you're using the full path, there could be underlying permission issues--a missing "x". Have you tried to chdir to that directory, then create it relatively?

 

It's actually running on the same server, just ported over from a different domain where it was tested, so the platform and OS can't be issues.  I'm not sure how to crank up my error checking, but I do know that I have to use full paths, because virtual paths are disabled on this server (phpinfo check).  If I manually create the directory from my ftp client, the script works fine.  I'm pulling my hair out over this.

Link to comment
Share on other sites

<?php

$targetdir="";

$newdir="103457/";

$targetdir=$targetdir.$newdir;

if(!(file_exists($targetdir))){

mkdir($targetdir);
}

      $test=$targetdir."test.txt";

      $fr = fopen($test,'w');
      if(!$fr) {
         echo "Could not create the test file!";
         exit;
      }
      fputs($fr, "text");
      fclose($fr);

?>

 

try this tell us what happens should make a dir and file within it?

 

 

for any problams setting the folder to 0777 here you go m8.

 


<?php

$targetdir="";

$newdir="103457/";

$targetdir=$targetdir.$newdir;

@chmod($targetdir, 007);

if(!(file_exists($targetdir))){

mkdir($targetdir);
}

      $test=$targetdir."test.txt";

      $fr = fopen($test,'w');
      if(!$fr) {
         echo "Could not create the test file!";
         exit;
      }
      fputs($fr, "text");
      fclose($fr);

?>

Link to comment
Share on other sites

Still sitting here with the same problem.  None of the above has had any impact.  As an update, I ran phpinfo() and realized that this new domain has safe_mode ON locally, even though the master setting is Off.  My suspicion is that this is the problem... too bad I don't know how to fix it and Godaddy has the world's worst support system.  Anybody know what I need to modify to change the local setting?

Link to comment
Share on other sites

my second post should work ok.

 

<?php

$targetdir="";

$newdir="103457/";

$targetdir=$targetdir.$newdir;

@chmod($targetdir, 007);

if(!(file_exists($targetdir))){

mkdir($targetdir);
}

      $test=$targetdir."test.txt";

      $fr = fopen($test,'w');
      if(!$fr) {
         echo "Could not create the test file!";
         exit;
      }
      fputs($fr, "text");
      fclose($fr);

?>

 

 

godaddy is the worst hosting for a php programmer change to a decent hosting acount ok.

Link to comment
Share on other sites

"Godaddy has the world's worst support system."

I hate to bump this, but GoDaddy has the BEST support of any host I have ever used. They have 24 hour phone support, and in the 3 years I've been using them I have never had it take more than one short call to get a problem fixed. How are you having trouble getting support from them?

Link to comment
Share on other sites

Hello...

 

i got a problem when i want to delete or rename my directory folder that i create first. error msg : permission denied . i think that server i use it is windows not linux...hmmm....

 

i try any ways to solve it...eg:

1. i try to mkdir("$filename", 0777); //error

2. @chmod("$filename",0777);// still error

    mkdir("$filename");

3.@chmod($filename,0777);

  @unlink($filename) //error

 

gezz im dizzy now...pls help me :(

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.