Why? PHPcodefunctiondelDir ($ dir) {$ arr = getcTime ($ dir); asort ($ arr); // $ arr = array ('file name' = & gt; 'creation time') why?
PHP code
Function delDir ($ dir) {$ arr = getcTime ($ dir); asort ($ arr ); // $ arr = array ('file name' => 'creation time'); // getDirSize ($ dir) is the function for obtaining the folder size based on the folder directory foreach ($ arr as $ key => $ value) {$ size = getDirSize ($ dir); if ($ size> 2048) {unlink ($ key) ;}else {break ;}}}
In win, it is OK. However, the following error occurs in linux.
Warning: unlink (/usr/local/lamp/test/2. text) [function. unlink]: Permission denied in/usr/local/lamp/apache2/htdocs/test. php on line 112
I checked on the Internet, and some said it was a permission issue, but I set the permission for the test folder to 777 ,,,
What are the reasons for this? It really hurts...
------ Solution --------------------
Use is_writable to check the permissions before unlink.
PHP may only use the user name (usually 'nobody') for running webserver to access the file.
------ Solution --------------------
Discussion
Reference:
Do you want to delete files other than the website?
No. this is just a test file to delete the log file.
------ Solution --------------------
Discussion
Reference:
Reference:
Reference:
Standard answer
Cut
2. the text permission is not correct. you can allocate xx to this file to the apache operation...
The account for running apache is root. Permission:-rwxrwxrwx root
I'm sure and sure ......
... The zookeeper of apache is root ?? So painful ......