?
Solved

mkdir in CakePHP

Posted on 2010-04-05
1
Medium Priority
?
2,689 Views
Last Modified: 2012-06-22
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:
/Users/mickoc/Sites/cake/cakecms/webroot/files/cache/150x150

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;
        
       if(!is_dir($relpath)) 
        { 
            mkdir($relpath); 
        }

Open in new window

0
Comment
Question by:moconn
1 Comment
 
LVL 15

Accepted Solution

by:
Phil Phillips earned 2000 total points
ID: 29869851
You need to make sure that the path '/Users/mickoc/Sites/cake/cakecms/webroot/files/cache' exists before attempting to create the '150x150' directory.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question