Start a conversation

Manipulating folders in PHP

To create folders by the PHP should use the mkdir() function to remove should use rmdir() function.

mkdir() function:

In mkdir function you must indicate which way the folder and the security level is created (0777,0755,0644, ...).

rmdir() function:

In rmdir function you must indicate the full path to the folder.

In the Windows the security parameter is ignored because only apply to Linux.

Manipulating the creation of directories:

We have a form for handling creating folders:

In the event just OnAfterInsert must insert the following line:

mkdir ($ _SERVER['DOCUMENT_ROOT']'/scriptcase/file/'.{directory_name}, 0755);

$ _SERVER['DOCUMENT_ROOT']: Full path to the web server, in this example: / opt/NetMake/v71/wwwroot
/scriptcase/file/: path to your directory after wwwroot.
{directory_name}: Field form.

On the final parameter:
You should put 0755 to web servers and 0755 to local server when running your application .

So after insertion be performed, the new directory will be created:

In OnBeforeDelete event you should use rmdir() function to delete the directory created.
rmdir ($ _SERVER['DOCUMENT_ROOT']'/scriptcase/file/'.{directory_name);

Choose files or drag and drop files
Was this article helpful?
  1. Ronyan Alves

  2. Posted
  3. Updated