FUNKAM35 Posted February 23, 2014 Share Posted February 23, 2014 Hi, I would like to upload photos to my database but need each set of folders to be in their own folder which will be the $reference I can upload the photos ok but dont know how I can make it create a folder named $reference Many Thanks Quote Link to comment https://forums.phpfreaks.com/topic/286458-creating-a-new-folder-with-php/ Share on other sites More sharing options...
Ch0cu3r Posted February 23, 2014 Share Posted February 23, 2014 (edited) but dont know how I can make it create a folder named $reference Do you mean create a folder using the value stored in the $reference variable. If that is the case, you'd just pass that variable to mkdir mkdir($reference); If you want to create folder in a specific place, then you'll need to prepend the parent path mkdir('path/to/patent/folder/'.$reference); Edited February 23, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/286458-creating-a-new-folder-with-php/#findComment-1470306 Share on other sites More sharing options...
.josh Posted February 23, 2014 Share Posted February 23, 2014 // this is the path to where your folders are located $basePath = 'path/to/where/folders/go/'; // the folder name you are saving/retrieving in your database. $reference = 'somefolder'; //this is the full path/to/folder $folder = $basePath.$reference; // if the folder doesn't already exist... if (!file_exists($folder)) { // create the folder mkdir($folder); } Quote Link to comment https://forums.phpfreaks.com/topic/286458-creating-a-new-folder-with-php/#findComment-1470307 Share on other sites More sharing options...
FUNKAM35 Posted February 23, 2014 Author Share Posted February 23, 2014 Many thanks will try this and report back once tried Quote Link to comment https://forums.phpfreaks.com/topic/286458-creating-a-new-folder-with-php/#findComment-1470312 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.