When uploading an image, I want to display the image by year, month, or day based on the current date, so I have the following code {code ...} the above code is successfully tested in a local testing environment (PHP + apache + MySQL. However, when I upload code to the server, the following error is reported: Warning: mkdir () [fun... when uploading an image, I want to display the image by year, month, or day based on the current date, so I have the following code:
The above code is successfully tested in a local testing environment (PHP + apache + MySQL. However, when I upload code to the server, the following error will be reported:
Warning: mkdir () [function. mkdir]: open_basedir restriction in effect. file (D: \ hosting) is not within the allowed path (s): (D: \ hosting \ wwwroot \; D: \ hosting \ System \; C: \ WINDOWS \ Temp \) in D: \ hosting \ wwwroot \ obbzz_com \ htdocs \ mytest. php on line 47
What is the cause of this situation?
Reply content:
When uploading an image, I want to display the image by year, month, or day based on the current date, so I have the following code:
The above code is successfully tested in a local testing environment (PHP + apache + MySQL. However, when I upload code to the server, the following error will be reported:
Warning: mkdir () [function. mkdir]: open_basedir restriction in effect. file (D: \ hosting) is not within the allowed path (s): (D: \ hosting \ wwwroot \; D: \ hosting \ System \; C: \ WINDOWS \ Temp \) in D: \ hosting \ wwwroot \ obbzz_com \ htdocs \ mytest. php on line 47
What is the cause of this situation?
There is a problem where you generate multi-level directories. php cannot generate multi-level directories at a time.date("Y/m/d")
, You must check whether the directory exists cyclically. if it does not exist, create another level.
Apparently, I have not read the official PHP documentation.
Http://php.net/manual/en/function.mkd...
Bool mkdir (string $ pathname [, int $ mode = 0777 [, bool $ recursive = false [, resource $ context])
The third parameter is true, similar to File. mkdirs in Java.
The following is my function, which is quite useful.
function mkdirs($dir) { if(!is_dir($dir)) { if(!mkdirs(dirname($dir))){ return false; } if(!mkdir($dir,0777)){ return false; } chmod($dir, 0777); } return true; }