Home Tutorial Php Examples Copy text file in a HTML form.

 
 

Copy text file in a HTML form.
Posted on: July 30, 2009 at 12:00 AM
Advertisement
This is the example of copying text file using HTML form.

Copy Text File in a HTML form

For copying a text file from one source to other destination in HTML form, you will have to create a HTML form and call the form action into php code to copy the file.

In PHP code, first begin the PHP tag,

Define the source file and destination file variable.

Copy file from source to destination.

End php tag.   

<?php
if($_POST["copy"]){
$sourcefile = $_POST["sourcefile"];
$destinationfile = $_POST["destinationfile"];
copy($sourcefile,$destinationfile);
}
?> 

Draw the HTML form

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>Copy File</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<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"> 
<tr>
<td colspan="4" align ="center"><h3>Copy Text File</h3></td>
</tr>
<tr>
<td><strong>Source File</strong></td>
<td><input type="file" id="sourcefile" name="sourcefile"></td>
<td><strong>Destination File</strong></td>
<td><input type="file" id="destinationfile" name="destinationfile"></td>
</tr>
<tr>
<td> </td> <td> </td><td><input type="submit" name="copy" value="Copy"/></td> 
</tr>
</table>
</form>
</body>
</html>

Advertisement

Related Tags for Copy text file in a HTML form.:


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
 

 

 

DMCA.com