diff --git a/imagefield_zip.module b/imagefield_zip.module
index a360ccc..8d9f822 100644
--- a/imagefield_zip.module
+++ b/imagefield_zip.module
@@ -359,7 +359,7 @@ function imagefield_zip_extract($filepath) {
     $file_dest = $dest . '/' . $entry_name;
     $parent_dir = dirname($file_dest);
     if (!file_exists($parent_dir)) {
-      mkdir($parent_dir, 0777, TRUE);
+      imagefield_zip_mkdir_recursive($parent_dir);
     }
 
     // Create temp target file.
@@ -508,3 +508,21 @@ function imagefield_zip_error($errno) {
   }
   return 'Zip File Function error: unknown ' . $errno;
 }
+
+/**
+ * Recursive make directory, returns TRUE if exists or made.
+ *
+ * @param string $pathname
+ *   The directory path.
+ * @return boolean
+ *   returns TRUE if exists or made or FALSE on failure.
+ */
+function imagefield_zip_mkdir_recursive($pathname, $mode = 0777) {
+  if (is_dir($pathname)) {
+    return is_dir($pathname);
+  }
+  if (!is_dir(dirname($pathname))) {
+    mkdir_recursive(dirname($pathname), $mode);
+  }
+  return @mkdir($pathname, $mode);
+}
