Create folders and files in php on linux

Source: Internet
Author: User
Create a folder and file test in php in linux. php file: $ dir = & quot ;. /OK/& quot; $ result = mkdir ($ dir, 0777); echo $ result; I wrote this code to create a folder... it is possible in the window .. but it won't work in linux .. l create folders and files in php in linux
Test. php file:
$ Dir = "./OK /";
$ Result = mkdir ($ dir, 0777 );
Echo $ result;
I wrote such a piece of code to create a folder... it works in the window ..
But it won't work in linux ..
The linux environment is good. other products can be supported.
And I have 0777 permission for the test. php file ....


But it still fails to be created... and no error is reported... it is blank.

------ Solution --------------------
Do all the parent folders of the file you created have the write permission ???
------ Solution --------------------
In theory, it should be okay. But I have never tried Linux

PHP code
 
$ Dir = dirname (_ FILE _). "./OK ";
Echo mkdir ($ dir, 0777 )? 'OK': 'failed ';



Open the directory and check whether the directory has been created ~


------ Solution --------------------
This has nothing to do with whether the test. php is 777.

The problem is whether your apache permissions have the write and execution permissions on the current folder.

We recommend that you set the current folder to 777 and try your code again.

Of course, if a folder with the same name already exists, the creation will fail.
------ Solution --------------------
You must have the permission to create the php file of the folder...
Check whether apache has the creation permission.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.