mkdir in CakePHP

Hi guys,

I'm having trouble with a simple mkdir function in CakePHP.

Code attached.

Basically all I'm trying to do is check to see if the dynamic cached dir exists in my /webroot/files/ directory and if not create it using mkdir.

The variable $relpath resolves to:

So it should check using is_dir to see if this dir exists (it doesn't right now) and if not it should create it.

I'm getting the following error:
Warning (2): mkdir() [function.mkdir]: No such file or directory [APP/views/helpers/image.php, line 33]

Any help appreciated..

function resize($path, $width, $height, $aspect = true, $htmlAttributes = array(), $return = false, $urlonly = false) {
      $dir = "{$width}x{$height}";
      $fullpath = WWW_ROOT.'files'.DS;
      $relpath = $fullpath.'cache'.DS.$dir;

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Phil PhillipsDirector of DevOpsCommented:
You need to make sure that the path '/Users/mickoc/Sites/cake/cakecms/webroot/files/cache' exists before attempting to create the '150x150' directory.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.