Location: PHPKode > scripts > Convert Text to (X)HTML > convert-text-to-x-html/index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Text to HTML</title>
<style type="text/css">
 * {
	 font:15px "Lucida Sans Unicode", "Lucida Grande", sans-serif;
	 text-transform:capitalize;
	 font-variant:small-caps;
	 color:#333;	 
	 }
 body {
	 background:#fefefe;
	 margin:0;
	 padding:0;
	 text-align:center;
	 }
 #maincontainer {
	 margin:0 auto;
	 width:80%;
	 height:600px;
	 position:relative;
	 }	 
  #text {
	 position:absolute; 
	 bottom:20px;
	 left:20px;
	 width:47%;
	 height:350px;
	 border:1px solid #aaa;
 	 background:#f5f5f5;
	 text-align:left;
	 font:normal normal normal 20px "Courier New", Courier, monospace;
	 text-transform:none;
	  }	 
  #html {
	 position:absolute; 
	 bottom:20px;
	 right:20px;
	 width:47%;
	 height:350px;
	 border:1px solid #aaa;
	 background:#f5f5f5;
	 text-align:left;
	 font:normal normal normal 15px "Courier New", Courier, monospace;
	 text-transform:none;
	 color:#f38;
	 overflow:scroll;
	  }	 
  xmp {

	 text-align:left;
	 font:normal normal normal 14px "Courier New", Courier, monospace;
	 text-transform:none;
	 color:#222;

	  }  
  #form {
	 position:absolute; 
	 top:20px;
	 left:20px;
	 width:95%;
	 height:200px;
	 border:1px solid #aaa;
	 background:#f5f5f5;
	  }	 
</style>
</head>
<body>

<div id="maincontainer">

<div id="form">
<br />
<form action="./" method="post" enctype="multipart/form-data">

 <label for="file">Select your Text file: </label>
 <input type="file" name="file" id="file" /><br /><br />

 <label for="doctype">Select your DocType: </label>
 <select name="doctype" id="doctype">
    <option value="None">None</option>
    <option value="HTML_4.01_Transitional">HTML 4.01 Transitional</option>
    <option value="HTML_4.01_Strict">HTML 4.01 Strict</option>
    <option selected="selected" value="XHTML_1.0_Transitional">XHTML 1.0 Transitional</option>
    <option value="XHTML_1.0_Strict">XHTML 1.0 Strict</option>
    <option value="XHTML_1.1">XHTML 1.1</option>
    <option value="XHTML_Mobile_1.0">XHTML Mobile 1.0</option>
 </select><br /><br />
 <button type="submit">Convert Text to HTML ( Copy and Paste )</button>
 </form><br />


<?php
$auth = false;
if(isset($_FILES['file'])) {
	
	$tmp = $_FILES['file']['tmp_name'];
	$name = $_FILES['file']['name'];
	$doctype = $_POST['doctype'];
	
	
	if(is_uploaded_file($tmp)) {
		
		move_uploaded_file($tmp,"./upload/$name");
		
		}
	if($_FILES['file']['error'] == 0) {
		
		$file = "./upload/$name";
		$text = nl2br(file_get_contents($file));
		
		$auth = true;
		$info = pathinfo($file);
   	    $name = $info['filename'];
		include_once("convert_engine.php");						
		
		$html = $chtml;
		
		
		}	
	
	
	}

?>

 <?php
  if($auth) {
 ?>
 <form action="download_engine.php" method="post">
 <input type="hidden" name="download" id="download" value="<?php echo "$name.html"; ?>" />
 <button type="submit"> Download HTML File </button> 
 </form>
 <?php
 }
 ?>

</div>


<div id="text">

<span style="color:#f38;font:15px 'Courier New', Courier, monospace;">Text</span> <br />

 <?php
 
 echo $text;
 
 ?>

</div>

<div id="html">

HTML <br />

 <xmp><?php echo $html; ?></xmp>

</div>


</div>

</body>
</html>
Return current item: Convert Text to (X)HTML