Please help me! [mkdir]

Started by Makavelli, December 29, 2004, 03:42:56 PM

Previous topic - Next topic

Makavelli

I tried creating a directory using this function but it creates a binary file instead with permission 644

$dir = "pics/104";
[at]mkdir($dir,0777);

What am I doing wrong? Please help me!!  :'(


-------
Operating system Linux
Kernel version 2.4.28-ow1
Apache version 1.3.33 (Unix)
PERL version 5.8.4
Path to PERL /usr/bin/perl
PHP version 4.3.10
MySQL version 4.0.22-standard
-------------

If you fall stand tall and come back for more- Pac

Christian A. Herrnboeck

Try this:


<?php
$dir
= '/test/';
mkdir($dir,0777);
?>


It works ;-) Also, why are you using the @? You shouldn't need it, if it is giving an error without the @, please post it so we can help.

Christian


Farmers:Producing food for the world!

Makavelli

Usage: echo getFoldersize('/pics/104/');
Error: mkdir(/pics/104/): File exists in misc.php on line 95.
Result: Error creating/opening folder ./pics/104/   

I noticed that it gives this error even if I delete the folder that already existed before running the script. Could it have anything to do with permission?

function getFoldersize($dir){

if (!is_dir($dir)){
   mkdir($dir, 0777); //<<<< line 95
}

if (is_dir($dir) && is_readable($dir)){
$d = opendir($dir);

$totalsize = 0;

while(false != ($f = readdir($d))) {
    if(is_file($dir.'/'.$f))
        $totalsize += filesize($dir . '/' . $f);
}

$remainsize =10485760-$totalsize;
$unused = (bytes_to_hr($remainsize));
$totalused = (bytes_to_hr($totalsize));
$per = round(($totalsize/10485760)*100,0);
$remainper = 100-$per;

$table = $totalused.' ('.$per.'%) of of 10MB used';
}else {
$table = 'Error creating/opening folder '. $dir .';

}
return $table;
}
If you fall stand tall and come back for more- Pac

[Unknown]

Delete the file "104" and then try again.

-[Unknown]

Makavelli

Still the same problem. I'm dying here  :-[
If you fall stand tall and come back for more- Pac

Advertisement: