Index: imagecache.module
===================================================================
--- imagecache.module	(revision 2)
+++ imagecache.module	(revision 3)
@@ -424,14 +424,26 @@
 }
 
 /**
- * A recursive mkdir.
+ * A recursive mkdir. Implements a Unix 'mkdir --parents --mode=755'
  */
 function _imagecache_mkdir($dir) {
+  $initial = substr($dir, 0) ? '/' : '';
+  
   $folders = explode('/', $dir);
-
-  foreach ($folders as $folder) {
-    $dirs[] = $folder;
-    $path = implode('/', $dirs);
+
+  foreach ($folders as $folder) {    
+
+    // A leading '/' in $dir causes an empty $folder. This happens when $dir is an absolute path.
+    // This is fact also the case in an otherwise valid path such as "/some//valid/path///name" which
+    // translates into "<empty>/some/<empty>/valid/path/<empty>/<empty>/name". 
+    // The following check skips all empty folders.
+    if($folder == '') {
+      continue; 
+    }
+    
+    $dirs[] = $folder;
+
+    $path =  $initial . implode('/', $dirs);
     if (is_dir($path)) {
       continue;
     }
