Jump to content

read text files using stream tokenizer in javascript


Recommended Posts

I don't think Javascript has a string tokenizer built-in. What code are you using? Also, which text files are *the* text files?
Good Day!Thanks for your reply.here is my code:
function validateBinType(objRow){	alert('Page is loaded!')	var filename = '<%= filename %>' // i got this in my readFile.jsp page	myFileSysObj = new ActiveXObject("Scripting.FileSystemObject");	file = myFileSysObj.GetFile(filename);	var myInputTextStream = myFileSysObj.OpenTextFile(file, 1, true);	var myOutputTextStream = myFileSysObj.OpenTextFile(file, 2, true);	while(!myInputTextStream.AtEndOfStream)	{	  file = myOutputTextStream.Write(myInputTextStream.ReadAll());	  if(file.value == 0)//if the content of the file contains 0...			{				rowColor = 'red'; 				}	  else if(file.value == 0)			{				rowColor = 'green';			}					objRow.bgColor = rowColor;		}			myInputTextStream.Close();		myOutputTextStream.Close();	}...and this is my index.jsp page<HTML><HEAD></HEAD><BODY bgcolor="#33b9ec><H2 align="center"> Strip Map Reader</H2><FORM METHOD="POST" ACTION="readFile.jsp" name="formName">	<TABLE align="center" border="1" bgcolor="#2b6095" cellspacing="10" cellpadding="4">		<TR>		 <TD><font color="white">Please specify a file, or a set of files: <br>		 <INPUT TYPE="File" SIZE=40 NAME="textFileName" style="background: white;"> </TD>						</TR>			 <tr>	<td>	<center>	<INPUT TYPE=submit VALUE="Upload" style="width: 70px">	<INPUT TYPE=reset VALUE="Reset" style="width: 70px">	</center>	</td>	</tr> </TABLE>	</FORM></BODY></HTML>

i want to get or read the content of text file(e.g. sample.txt) uploaded in jsp page using javascript..how can i do that?

Link to comment
Share on other sites

Javascript alone can't access a file on disk, either on the server or the client. You need to use server-side code to access the files on the server, and you can't access the files on the client.
Good Day!What will i do to access the files either on the server or client? can u give me a sample code....? thanks!:-)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...