Hello I'm looking for a small update to my image upload script Currently the images are uploaded from my computer or url using a custom wordpress template then ran through imagemagick and stored in /reversed/ folder - The update I require is to store the images in public_html/wp-content/uploads/"year"/"month"/"day". as the next part of the script creates a new post in wordpress and attaches the image so I’m wanting the image uploads in the corresponding date folder I’m sure this can easily be done using the below code but maybe a built in wordpress function can do this better $base_dir = '/public_html/wp-content/uploads'; $new_dir = $base_dir.date('/Y/m/d/'); if(!file_exists($new_dir) AND is_writable($base_dir)) { mkdir($new_dir, 0777, true) } Many Thanks
Must create one by one dir, can't create dir and 2 subdir in same time: $base_dir = '/public_html/wp-content/uploads'; $new_dir_Y = date('Y'); $new_dir_m = date('m'); $new_dir_d = date('d'); if(is_writable($base_dir)) { mkdir($base_dir."/".$new_dir_Y, 0777, true); mkdir($base_dir."/".$new_dir_Y."/".$new_dir_m, 0777, true); mkdir($base_dir."/".$new_dir_Y."/".$new_dir_m."/".$new_dir_d, 0777, true); $new_dir=$base_dir."/".$new_dir_Y."/".$new_dir_m."/".$new_dir_d; }