webspeed vs javascript?

FredJason

New Member
im creating a textfile/document in webspeed using OUTPUT. it will create at the server. my problem is how do i get or open the textfile/document i create in server, using javascript in the client side??

in my localhost its running using this code in javascript.
var fileSource = '\\MywebSite\\Documents\\sample.doc';

when i transfer my code in server and test with the client its not working.
please help me.
 

lee.bourne

Member
Could you give an example of what the file contains and what you intend using if for?

If you need to parse the file then the usual way to retrieve it would be via an AJAX call, in this case the file would usually be in XML or JSON format.

If you just want to display the file then maybe it's just something as simple as document.location.href = "http://yourserver/Documents/sample.doc"
 

FredJason

New Member
its a report template, that can be edit and save in the physical computer. i try your document.location.href = "http://yourserver/Documents/sample.doc". i cannot locate the server. about XML or JSON im not familiar, can u give me a code snippet?

thanks lee!
 

lee.bourne

Member
I hope you replaced the 'yourserver' bit with the domain name of your server?

Also, make sure the document you're writing is in the web server's documents directory (or subdirectory) and has the right permissions as so is actually accessible.

In terms of AJAX, you could try looking here: http://www.w3schools.com/ajax/ajax_xmlhttprequest_create.asp

However, perhaps you should avoid the whole saving the file to the server completely. Try using webspeed to stream the file back to the client without saving it.

Just change your existing html headers to something like this:

output-http-header ("Content-disposition":U, "Attachment~; filename=filename.txt").
output-content-type ("text/plain; charset=iso-8859-1":U).

Note, you will almost definitely have to change the mime type from text/plain to whatever is appropriate to your file type, maybe application/msword. and also the filename bit.

If you want to stream a file that is already saved on the disk then try this code snippet: http://freeframework.sourceforge.net/downloads/new/streamfile/readme.shtml
 

FredJason

New Member
ahaha! of course i change the doamin name. i try the output-http-header.. i hope i will find a way to find the server.. :(
 
Top