Read file or URL Example

From PlainOldWebserver

Jump to: navigation, search

HTML form and JavaScript CGI page to go with it to read a process a url or file you name.


readfile.html

<html>
<head>
</head>
<body>
<blockquote>

<h4>Read file or URL:</h4>
<form  method='Get' action='read.sjs'>
File Name or Url: <input size="60" name="fileurl"><br>

<INPUT TYPE='SUBMIT' VALUE='echo'>

</form>

</blockquote>
</body>
</html>


read.sjs

<?sjs

// This gets the variables from the form in echo.html 
fileurl   =  pow_server.GET['fileurl'];
 
// these lines clear up the urlencoded variables that were returned  
 
fileurl =  unescape(fileurl.replace(/\+/g," ")); 

// load the content or the file or url into "contents"

var contents = pow_file(fileurl)

 
                            
?>

<html>
<body>
<blockquote>
<h3>The Contents of <a href="<?sjs  document.write(fileurl);   ?>">
<b><?sjs  document.write(fileurl);   ?></b></a>   are below</h3>

<hr>

<?sjs  document.write(contents);   ?>

</blockquote>
</body>

</html>
Personal tools
Navigation