create file

Hi,

Below is the Java script code to create a text file through the browser. When you run the code, a dialog box appears and ask if you want to run the ActiveX control. If yes, the the file is created else no file is created.

APPLICATION: When a customer provides information such as name, email, comments and etc. on a form; I want to capture the information and put it on my hard drive for future data processing.

QUESTION: Does anyone know how to suppress the dialog box that asks to run the ActiveX control? Is there an alternative way of creating a file through the brower?

( If you have codes, it would be nice to have. )


**********************************************


Create File

<! This function will create a file named 'newfile' on the same directory as the HTML unless path is given>


function openFile()
{ var filePath = 'c:/filename.txt';
var fileSysObj = new ActiveXObject('Scripting.FileSystemObject');

fileSysObj.CreateTextFile(filePath);
}




This will create a file called "filename.txt" on your c: drive.

You must accept the ActiveX control or disable prompting to create a file.

create file






Comments

  • Another question then: Say you have the right permissions, is it possible to create a file on the server in the same way. Or is that not possible bcz JS is a client-side scripting language?

    : Hi,
    :
    : Below is the Java script code to create a text file through the browser. When you run the code, a dialog box appears and ask if you want to run the ActiveX control. If yes, the the file is created else no file is created.
    :
    : APPLICATION: When a customer provides information such as name, email, comments and etc. on a form; I want to capture the information and put it on my hard drive for future data processing.
    :
    : QUESTION: Does anyone know how to suppress the dialog box that asks to run the ActiveX control? Is there an alternative way of creating a file through the brower?
    :
    : ( If you have codes, it would be nice to have. )
    :
    :
    : **********************************************
    :
    :
    : Create File
    :
    : <! This function will create a file named 'newfile' on the same directory as the HTML unless path is given>
    :
    :
    : function openFile()
    : { var filePath = 'c:/filename.txt';
    : var fileSysObj = new ActiveXObject('Scripting.FileSystemObject');
    :
    : fileSysObj.CreateTextFile(filePath);
    : }
    :
    :
    :
    :
    : This will create a file called "filename.txt" on your c: drive.
    : You must accept the ActiveX control or disable prompting to create a file.
    :
    : create file
    :
    :
    :
    :
    :
    :
    :

  • Your question depends on your system. If this code resides on a server that runs an application (like IBM Data Director) that hides the codes and does other stuff such as ours, the file will sit on our server.

    Otherwise, the client CAN NOT put a file on the server for security reasons, making the code below to be a client side only when used alone.

    Creating a file could also be done via CGI or EXE without the client even knowing. But it must already reside on the server to be called.

    We have an EXE already creating a file but I am limited to changing it, that is why I am looking for an alternative way in creating a file.

    For simple forms, you might want to look into a guestbook. Where a user enters information and you can save the form information on your server. I believe, MS Frontpage create files as well if you have the development extension installed on the server.

    Do you know anyone who knows an alternative way in creating a file? Or possibly some good website?

    : Another question then: Say you have the right permissions, is it possible to create a file on the server in the same way. Or is that not possible bcz JS is a client-side scripting language?
    :
    : : Hi,
    : :
    : : Below is the Java script code to create a text file through the browser. When you run the code, a dialog box appears and ask if you want to run the ActiveX control. If yes, the the file is created else no file is created.
    : :
    : : APPLICATION: When a customer provides information such as name, email, comments and etc. on a form; I want to capture the information and put it on my hard drive for future data processing.
    : :
    : : QUESTION: Does anyone know how to suppress the dialog box that asks to run the ActiveX control? Is there an alternative way of creating a file through the brower?
    : :
    : : ( If you have codes, it would be nice to have. )
    : :
    : :
    : : **********************************************
    : :
    : :
    : : Create File
    : :
    : : <! This function will create a file named 'newfile' on the same directory as the HTML unless path is given>
    : :
    : :
    : : function openFile()
    : : { var filePath = 'c:/filename.txt';
    : : var fileSysObj = new ActiveXObject('Scripting.FileSystemObject');
    : :
    : : fileSysObj.CreateTextFile(filePath);
    : : }
    : :
    : :
    : :
    : :
    : : This will create a file called "filename.txt" on your c: drive.
    : : You must accept the ActiveX control or disable prompting to create a file.
    : :
    : : create file
    : :
    : :
    : :
    : :
    : :
    : :
    : :
    :
    :

  • I already thought it isn't possible to create a file on the server with JavaScript, but I thought I'd ask it anyway. The reason I asked it, is that I maintain and develop websites on four or five different servers.
    Some of them support CGI, some of them support PHP, some of them support ASP and some of them support neither.
    I learned from this thread anyway, that JavaScript is a good compromise but not suitable for developing "complex" websites.
    I'll just inform some people that it's not possible for them to host a guestbook or poll.

    Thanks anyway for the reactions.

    : Your question depends on your system. If this code resides on a server that runs an application (like IBM Data Director) that hides the codes and does other stuff such as ours, the file will sit on our server.
    :
    : Otherwise, the client CAN NOT put a file on the server for security reasons, making the code below to be a client side only when used alone.
    :
    : Creating a file could also be done via CGI or EXE without the client even knowing. But it must already reside on the server to be called.
    :
    : We have an EXE already creating a file but I am limited to changing it, that is why I am looking for an alternative way in creating a file.
    :
    : For simple forms, you might want to look into a guestbook. Where a user enters information and you can save the form information on your server. I believe, MS Frontpage create files as well if you have the development extension installed on the server.
    :
    : Do you know anyone who knows an alternative way in creating a file? Or possibly some good website?
    :
    : : Another question then: Say you have the right permissions, is it possible to create a file on the server in the same way. Or is that not possible bcz JS is a client-side scripting language?
    : :
    : : : Hi,
    : : :
    : : : Below is the Java script code to create a text file through the browser. When you run the code, a dialog box appears and ask if you want to run the ActiveX control. If yes, the the file is created else no file is created.
    : : :
    : : : APPLICATION: When a customer provides information such as name, email, comments and etc. on a form; I want to capture the information and put it on my hard drive for future data processing.
    : : :
    : : : QUESTION: Does anyone know how to suppress the dialog box that asks to run the ActiveX control? Is there an alternative way of creating a file through the brower?
    : : :
    : : : ( If you have codes, it would be nice to have. )
    : : :
    : : :
    : : : **********************************************
    : : :
    : : :
    : : : Create File
    : : :
    : : : <! This function will create a file named 'newfile' on the same directory as the HTML unless path is given>
    : : :
    : : :
    : : : function openFile()
    : : : { var filePath = 'c:/filename.txt';
    : : : var fileSysObj = new ActiveXObject('Scripting.FileSystemObject');
    : : :
    : : : fileSysObj.CreateTextFile(filePath);
    : : : }
    : : :
    : : :
    : : :
    : : :
    : : : This will create a file called "filename.txt" on your c: drive.
    : : : You must accept the ActiveX control or disable prompting to create a file.
    : : :
    : : : create file
    : : :
    : : :
    : : :
    : : :
    : : :
    : : :
    : : :
    : :
    : :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories