Next up, a little file and directory manipulation. If you'd like to create directories, PHP provides the mkdir() function, which accepts a file path and a mode as parameters, So, if I wanted to create a directory called "/tmp/me" with permissions 755, I would use something like this: And to reverse the process, there's always the rmdir() function, used to delete directories. Note that rmdir() will fail if the directory permissions don't allow deletion, or if the directory contains one or more files. You can delete files with the unlink() function, which accepts a filename as parameter. <? if (unlink("/tmp/dummyfile")) { echo "Successful!"; } else { echo "Unsuccessful!"; } ?> And finally, you can copy files with the copy() function, and rename (or move) them with the rename() function.
This article copyright Melonfire 2000. All rights reserved.
blog comments powered by Disqus |