Data storage in local folder

Asked

Viewed 98 times

0

I have this script that was created by a colleague who is no longer active. The problem although it seems that everything is right has something wrong and I can’t find what it is. The goal of it is to store little data of a form in a folder created in the act of filling it. In this case the script should not only create a folder but also allow editing and deletion of the content. This script was made for internet explorer but if someone has an idea of a script that works in firefox would be better.

//Cria Objeto ActiveX
var dados = new ActiveXObject("Scripting.FileSystemObject");

//Função para gravar o arquivo
function GravarArquivo (arq,texto){
//pasta a ser salvo o arquivo
var pasta = "C:\Users\Convidado\Desktop\teste";

//se o parametro arq que é o nome do arquivo vier vazio ele salvará o arquivo com o nome “Sem Titulo”
if(arq==""){arq="Sem Titulo";}
//carrega o txt
var esc = dados.CreateTextFile(pasta+arq+".txt", false);
//escreve o que foi passado no parametro texto que é o texto contido no TextArea
esc.WriteLine(texto);
//fecha o txt
esc.Colose();
}
//Função para abrir o arquivo
fuction AbreArquivo (arq){
//o parametro arq é o endereço do txt
//carrega o txt
var arquivo = dados.OpenTextFile(arq, 1, true);
//varre o arquivo
while(!arquivo.AtEndOfStream){
//escreve o txt no TextArea
document.getElementById("texto").value = arquivo.ReadAll();
}
//fecha o txt
arquivo.Close();
}
  • This script will only work in some versions of I.E. Modern browsers no longer use Activex objects. I suggest that your data be recorded in Torage location, will work in all browsers.

  • You would have some script with the predicates similar to the one I posted but which make the recording at the Storage location?

  • I have several, but you are perfectly able to write them yourself. These 2 links in English explain very well: MDN file and other article. This article is from DEVMEDIA and is in Portuguese: link

  • If you want to follow by this path (Activex), there are other plugins for other browser that enable Activex, regarding the error, check the console which error is occurring with your code and post along with the question. I recommend the localStorage because besides being cross-platform it is a common language for persistent storage

  • Thanks. I’ll take a look and if you have any doubts I put here.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.