Jump to content

creating a new folder with php


FUNKAM35

Recommended Posts

 

 

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 by Ch0cu3r
Link to comment
Share on other sites

// 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);
}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.