I am using the iOS draft code php app. I have written some code that should make a file or directory. The code works fine for creating files but when a folder is made it shows up but I cannot manually open it. Relative code:
($folder?mkdir($path, 0755, true) : fopen($path, 'w')) or die('Cannot create file: '.$path);
$path
is a string with the path the file will be created and $folder
is a Boolean. What's wrong?
You are using fopen that is for files not for dirs try readdir:
($folder?mkdir($path, 0755, true) : readdir($path, 'w')) or die('Cannot create file: '.$path);
As others and the documentation state, fopen()
opens a file. To read directory contents, use readdir()
: https://secure.php.net/manual/en/function.readdir.php