Mime types
I am able to write a (client-side) page that writes a file with a .sql extension. I can edit the file with notepad and everything looks okay. When I try to open it with javascript, it displays rubbish on the screen. When I rename the same file to have a .txt extension, the javascript works fine. below is my open and save code.
Thanks...
function doSave() {
var win = window.open('', '_blank', 'top=10000');
win.document.open('text/html', '_blank');
win.document.charset="iso-8859-1";
win.document.writeln(form1.textarea1.value);
win.document.execCommand('SaveAs',true,'dbnet.sql' );
win.close();
}
function doOpen() {
var theFile=document.form2.InputFile.value;
theNewFile=theFile.replace(/\\/g, "\\\\");
var thisFile = new ActiveXObject("Scripting.FileSystemObject");
var ReadThisFile = thisFile.OpenTextFile(theNewFile,1,false);
var txtFile = ReadThisFile.ReadAll();
document.form1.textarea1.value=txtFile;
ReadThisFile.Close();
}
|