Click here to Skip to main content
15,921,295 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

ISSUE: I am working on HTML application, an HTML page contains a username, password and Login

button. When i enter the username and password and click Login button, i want to create a text

file and write the username in to the text file on the server side machine.


I have implemented the html page like above issue, but the main problem is when i call the html

page from the server in to the local machine through URL in Internet Explorer. When i enter the

Username and password the .txt file is not created at the server side.

The Page i implemented is like this,

XML
<html>
<title>Mutiara SMART</title>
<SCRIPT language="JavaScript">

function WriteFile()
{
   var username = document.getElementById('txtUserName').value;
   var Scr = new ActiveXObject("Scripting.FileSystemObject");
   var CTF = Scr.CreateTextFile("C:\\DataBuffer", true, true);
   CTF.WriteLine(username);
   CTF.Close();
}

</SCRIPT>
<head>

<link href="admin.css" rel="stylesheet" type="text/css">

</head>
<body>

<center>
<img src = "smart.jpg">
 <table width="350" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="gray" class="entryTable">
        <tr id="entryTableHeader">
         <td>:: Login ::</td>
        </tr>
        <tr>
         <td class="contentArea">

    <table width="100%" border="0" cellpadding="2" cellspacing="1" class="text">
           <tr align="center">
            <td colspan="3">&nbsp;</td>
           </tr>
           <tr class="text">
            <td width="100" align="right">Username </td>
            <td width="10" align="center">:</td>
            <td><input name="txtUserName" type="text" class="box" id="txtUserName" value="" size="30" maxlength="100"></td>
           </tr>
           <tr>
            <td width="100" align="right">Password </td>
            <td width="10" align="center">:</td>
            <td><input name="txtPassword" type="password" class="box" id="txtPassword" value="" size="30"></td>
           </tr>
           <tr>
            <td colspan="2">&nbsp;</td>
            <td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="javascript: CreateFile();">Login</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
           </tr>
          </table>

</center>

</body>

</html>



can anyone give an idea on how to create .txt file on server side.

Thank you in Advance.
Posted
Comments
The Magical Magikarp 2-Feb-20 20:28pm    
I know this is old,(Like, really old..) but why would you write the user logins to a text file..?(This is insecure for the user's login info.)

The basic thing is that the Javascript executes on CLIENT SIDE. If you are using ActiveX objects in Javascript to write the text file , then it will ( if it really works) write the file to client machine and not on the server.

This is where the server side scripting comes into picture. Create a dynamic webpage with server side coding where it writes a file to the disk on server.

You can explore ASP.NET, PHP and other web technologies
 
Share this answer
 
Comments
Аslam Iqbal 24-Feb-13 5:20am    
good reply. 5
bbirajdar 24-Feb-13 23:27pm    
Thank you Aslam :)
You can call Ajax request from client side and from that server side method will execute. That method will responsible to create text file. You just send username or other things as argument. You can check the Link. Mind it ActiveX object use it not recommended practive, only IE can support it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900