JavaScript Ability
Results 1 to 5 of 5

Thread: JavaScript Ability

  1. #1

    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.

  2. #2
    Senior Member
    Join Date
    Aug 2001
    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.

    <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 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

    <form runat="server" id="myForm">
    Create Text file
    <asp:linkbutton id="CreateFile" runat="server" onclick="CreateFile_Click" />
    <input type="hidden" runat="server" id="funcParam">


    for further info goto:
    \"Knowledge is the Real Power\"

  3. #3
    Senior Member
    Join Date
    Mar 2003
    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.

  4. #4
    Antionline Herpetologist
    Join Date
    Aug 2001
    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.
    Buy the Snakes of India book, support research and education (sorry the website has been discontinued)
    My blog:

  5. #5
    Senior Member
    Join Date
    Aug 2001
    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