Reputation: 1669
Well not much more to add, then what is in the title already, appart from maybe the actual bit of code:
$dir = dirname($local);// $local is absolute path to the file
if(!is_dir($dir));
mkdir($dir, 0755, true); //if $dir is not valid dir, lets create one
So, any ideas how I am still getting the file exists warning?
And here is the actualu warning, if that is of any help:
PHP Warning: mkdir(): File exists in /var/www/Import/Photo.php on line 67
Upvotes: 2
Views: 1822
Reputation: 56627
is_dir()
only tells you if a named path is a directory. There are other things that would block you from using mkdir()
, such as a regular file, a symbolic link... you probably should replace your test with something like this instead.
if (!file_exists($dir))
Also, the terminating semicolon after your if
statement means the mkdir()
is actually not being guarded by this test in the first place; it will run every time.
Upvotes: 3