Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check creation of new file/folder is allowed in client server using PHP code

In my site, I want to create new files or folders dynamically. I need to check if I have the permission to create new files and folders. How can i do this?

I also want to check if it is allowed PHP code execution is allowed in the client’s server. Is this possible?

like image 712
Kichu Avatar asked Jan 23 '26 23:01

Kichu


1 Answers

you can use: is_writable

eg:

if(is_writable('/path/to/your/dir/'))
{

}

from PHP Manual:

is_writable

Returns TRUE if the filename exists and is writable. The filename argument may be a directory name allowing you to check if a directory is writable.

Keep in mind that PHP may be accessing the file as the user id that the web server runs as (often 'nobody'). Safe mode limitations are not taken into account.

like image 195
Zul Avatar answered Jan 25 '26 13:01

Zul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!