PHP - Create Directory Dynamically
Submitted by razormist on Thursday, August 30, 2018 - 17:53.
In this tutorial we will create a Create Directory Dynamically Using PHP. PHP is a server-side scripting language designed primarily for web development. Using PHP, you can let your user directly interact with the script and easily to learned its syntax. It is mostly used by a newly coders for its user friendly environment. So Let's do the coding...
There you have it we successfully created Create Directory Dynamically using PHP. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!
Getting Started:
First you have to download & install XAMPP or any local server that run PHP scripts. Here's the link for XAMPP server https://www.apachefriends.org/index.html. And this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.Creating The Interface
This is where we will create a simple form for our application. To create the forms simply copy and write it into your text editor, then save it as index.php.- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/>
- <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
- </head>
- <body>
- <nav class="navbar navbar-default">
- <div class="container-fluid">
- <a class="navbar-brand" href="https://www.sourcecodester.com/">Sourcecodester.com</a>
- </div>
- </nav>
- <div class="col-md-3"></div>
- <div class="col-md-6 well">
- <h3 class="text-primary">PHP - Create Directory Dynamically</h3>
- <hr style="border-top:1px dotted #ccc;"/>
- <form method="POST" action="create_dir.php" class="form-inline">
- <label>Enter a text</label>
- <input type="text" name="dir" class="form-control">
- <button class="btn btn-primary" name="add"><span class="glyphicon glyphicon-plus"></span></button>
- </form>
- <br /><br />
- <table class="table table-bordered">
- <thead class="alert-success">
- <tr>
- <th>Directory</th>
- <th>Location</th>
- </tr>
- </thead>
- <tbody style="background-color:#fff;">
- <?php
- foreach($files as $file){
- ?>
- <tr>
- <td><?php echo $file."<br />";?></td>
- </tr>
- <?php
- }
- }
- ?>
- </tbody>
- </table>
- </div>
- </body>
- </html>
Creating the Main Function
This code contains the main function of the application. This code will create a directory on a target path. To make this just simple copy and write the this block of codes inside the text editor, then save it as create_dir.php.- <?php
- echo "<script>alert('You create directory successfully')</script>";
- echo "<script>window.location='index.php'</script>";
- }
- }
- ?>
Add new comment
- 1540 views