Home Tutorial Php Examples Creating a File in the directory.


Share on Google+Share on Google+
Creating a File in the directory.
Posted on: July 30, 2009 at 12:00 AM
In this example you will learn about creating a File in the directory.

Creating a file using HTML form action

In this example, you will learn to make a query form asking to to create a file in PHP. You will have to write the codes for HTML and PHP. 

First create a HTML form, then call the action form of PHP code in the form.

for creating a file in PHP, first declare a file name, define the path of destination where the file has to created. 

Print the file name and end the php cide.


$filename=fopen($name,"x") or exit("File Not Created.");
print "created";

Creating an action form in HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head><title>Create File</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body > 
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<table style="border:1px solid #CCCCCC; background-color:#F0F0F0; font-family:verdana; font-size:12px" cellpadding="5" cellspacing="2" width="600px"> 
<td><input type="text" id="destination" name="destination"></td>
<td> </td><td><input type="submit" name="create" value="Create"/></td> 


Related Tags for Creating a File in the directory.:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 30, 2009

Recommend the tutorial

Advertisements Advertisements