Create folder in php

2

I have to create a folder on the online server.

The file that creates folder is in site.com.br/example/files.php

I need to create the folder in the root of the site, example: site.com.br/archives/foldername

But every time says that the directory does not exist. I think that's why I'm not putting the correct url. I know that if mkdir (site.com.br) does not work ... how to proceed?

I am using the mkdir command ("/ public_html / filemanagerarquiv", 0777);

The site is within public_html.

    
asked by anonymous 14.09.2016 / 16:46

1 answer

4

You can try this example:

<?php

mkdir(__DIR__.'/arquivos/nome_da_pasta/', 0777, true);

?>

or

mkdir(dirname(__FILE__).'/arquivos/nome_da_pasta/', 0777, true);

Note that permission 777 allows full access to the folder, which is not wise in certain situations.

Check the required permissions here.

    
14.09.2016 / 17:31