PHP create multiple directories

php

Solution

Some of your subdirectories don't exist so you either need to iteratively create them or set the 3rd argument to `mkdir()` to `true`. Note that the second argument are the directory permissions (ignored on Windows) which default to `0777`.

You also need to set `$folder_full` to the root using `/`.

$folder_full = "/images/{$getFed}/{$country_folder}/stadiums";
if (!is_dir($folder_full)) mkdir($folder_full, 0777, true);

Problem

Let's say, in PHP, I am trying to put an image in a specific directory that is on root. I want to put it on `/images/afc/esp/stadium/` directory. Images folder, Federation folder, Country ISO3 folder, content folder. ``` $folder_full = "images/".$getFed."/".$country_folder."/stadiums"; if (!is_dir($folder_full)) mkdir($folder_full); ``` Before you ask, yes `$getFed` and `$country_folder` work and output text. So, then I get this error: `Warning: mkdir(): No such file or directory` I don't get it?

Original source