The directory and file structure is as follows:
C:\xampp\htdocs\PHP_Upload_Image_MKDIR\uploaded
C:\xampp\htdocs\testA.php // as follows
$userID = 's002';
$uploadFolder = '/PHP_Upload_Image_MKDIR/uploaded/';
$userDir = $uploadFolder . $userID;
mkdir($userDir, 0700);
If I call testA.php, then the following folder will be created.
C:\PHP_Upload_Image_MKDIR\uploaded\s002
However, the desired result should be the following:
C:\xampp\htdocs\PHP_Upload_Image_MKDIR\uploaded\s002
I would like to know a decent method so that the mkdir creates folder relative to the root of the web
C:\xampp\htdocs\
or
C:\wamp\www
Then in the future, I don’t have problems to move this application to a web hosting site.
Thank you
You can:
definewhat’s the server root (or whatever prefix) so that you prepend it to the directory.dirname(__FILE__).$_SERVER[DOCUMENT_ROOT](not a very good option, you might want your application in a subdirectory, and whether this value is available depends on the web server).