From: stefan-nowak-php at mailinator dot com Operating system: PHP version: 5.2.9 PHP Bug Type: Feature/Change Request Bug description: File & Directory Functions: Auto create intermediate directories from filepath
Description: ------------ It would be nice if all/some of PHP's file and directory functions would offer a flag AUTO_CREATE_DIRS, which would then cause these functions to automatically create directories for the given filepath, which yet don't exist. Many shell tools allow similar functionality (i.e: mkdir -p) Reproduce code: --------------- file_put_contents ( "/existing-dir/not-yet-existing-dir/file", "test"); // Warning: file_put_contents (existing-dir/not-yet-existing-dir/file): failed to open stream: No such file or directory Expected result: ---------------- file_put_contents ( "/existing-dir/not-yet-existing- dir/sub1/sub2/file.txt", "test", AUTO_CREATE_DIR); // If my sugestion would be implemented I would then expect PHP to automatically create the directories: // not-yet-existing-dir , sub1, sub2 // and the file: // file.txt -- Edit bug report at http://bugs.php.net/?id=48401&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48401&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48401&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48401&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48401&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48401&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48401&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48401&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48401&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48401&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48401&r=support Expected behavior: http://bugs.php.net/fix.php?id=48401&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48401&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48401&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48401&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48401&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48401&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48401&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48401&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48401&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48401&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48401&r=mysqlcfg
