Monday, May 27, 2013

Create folder in PHP

The following snippet will check whether folder exists with the path and creates the one.

if (!file_exists('../path/to/directory')) {
mkdir('../path/to/directory'.$id, 0755, True)}

The 3rd parameter 'True' is important here. If the full path is not present, true will help to create the path fully.

No comments:

Post a Comment