Share on Google+Share on Google+

Copy text file in a HTML form.

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.   

$sourcefile = $_POST["sourcefile"];
$destinationfile = $_POST["destinationfile"];

Draw the HTML form

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<head><title>Copy 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 colspan="4" align ="center"><h3>Copy Text File</h3></td>
<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>
<td> </td> <td> </td><td><input type="submit" name="copy" value="Copy"/></td> 


Posted on: July 30, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.