|
-
May 2nd, 2003, 12:48 AM
#1
Member
JavaScript Ability
Is it possible to create files on a webserver by JavaScript?
Also if you can, can you write to them etc?
I mean this so when the JS is ran it creates the file etc.
I know you can do this with more powerful scripting languages, but I'm just trying to find out JS's ability.
-
May 2nd, 2003, 02:51 PM
#2
Senior Member
create a link on a web page. when the user clicks on it it prompts the user for a file name, then created the file on the serverside.
<--snip-->
<script language="VB" runat="server">
Sub CreateFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim strFileName As String = funcParam.Value
'custom code to create a text file
End Sub
</script>
<html>
<head>
<script language="JavaScript">
//ask for user input and then create file
function CreateFile() {
//get filename from the user
var fileName = prompt('Type the name of the file you want to create:','');
//if the user clicks on OK and if they have entered something
if ((fileName) && (fileName!="")) {
//save the filename to the hidden form field 'funcParam'
document.forms['myForm'].elements['funcParam'].value = fileName;
//call the postback function with the right ID
__doPostBack('CreateFile','');
}
}
</script>
</head>
<body>
<form runat="server" id="myForm">
Create Text file
<asp:linkbutton id="CreateFile" runat="server" onclick="CreateFile_Click" />
<input type="hidden" runat="server" id="funcParam">
</form>
</body>
</html>
<---snap-->
for further info goto: http://www.xefteri.com/articles/dec102002/default.aspx
\"Knowledge is the Real Power\"
-
May 2nd, 2003, 11:07 PM
#3
ReLik: With just JS, no you cannot create server-side files or write to files.
.sig - There never was a .sig?
I own a Schneider EuroPC with MS-Dos 3.3 and it works.
-
May 3rd, 2003, 06:01 AM
#4
meister, please note that your code will only run on Windows (since it uses ActiveX) and Internet Explorer (since it uses VBScript). Otherwise, yes, it should work.
Cheers,
cgkanchi
-
May 3rd, 2003, 05:09 PM
#5
Senior Member
o.k., of course you're right cgkanchi
:-)
\"Knowledge is the Real Power\"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|