The ftp_mkdir() function is an inbuilt function in PHP which is used to create a new directory on the ftp server. Once the directory is created cannot be created again. Creating a directory that already exists will produce error.
string ftp_mkdir( $ftp_connection, $directory_name )
Parameter: This function accepts two parameters as mentioned above and described below:
- $ftp_connection: It is the required parameter and used to specify the ftp connection on which directory to be created.
- $directory_name:It is the required parameter and used to specify the name of the directory to be created.
If child directory is to be created in an existing or non-existing directory then the $directory_name parameter to be set in the format “(parent directory name)/(child directory name)/(child of child directory name)/…” so on. For example, create a directory named as childdirectory inside testdirectory then $directory_name = “testdirectory/childdirectory”;
Return Value: It returns the name of the directory that created on success, False on failure.
- This function is available for PHP 4.0.0 and newer version.
- The following example cannot be run on online IDE. So try to run in some PHP hosting server or localhost with proper ftp server name and correct username and password.
testdirectory Successfully created
Example 2: In case of child directory to be created then everything is same as before except $dir i.e. directory name.
testdirectory/childdirectory Successfully created
Note: If directory name already exist then it produce error.
- How to get the function name inside a function in PHP ?
- PHP | Ds\Set contains() Function
- p5.js | nf() Function
- p5.js | arc() Function
- p5.js | nfc() function
- p5.js | min() function
- PHP | dir() Function
- p5.js | second() function
- p5.js | hue() function
- CSS | url() Function
- PHP | Ds\Set first() Function
- p5.js | max() function
- PHP | Ds\Set last() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.