logo
Search:

Login:


Forgot Details? Sign-up

forum >> Programming questions >> HTML / XHTML / HTML5 / CSS

Windows Environmental Variables in HTML

Posted May 20 2012 at 1:09 PM by
Forrest Meiere (heritage)
Would like to open a txt file on a viewers computer using %AppData%/ICAClient/webica.ini as in
href="file:////%AppData%/ICAClient/webica.ini">webica.ini"
{inside an anchor tag; reluctant to enter actual code in forum}.

The corresponding href="file:////C:/Users/JohnDoe/AppData/Roaming/ICAClient/webica.ini"> works fine but different users have different names as well as different versions of Windows.

PS: Andy's book "PHP5/MySQL" changed my life a few years ago. Thanks
AuthorMessage
Andy
Posted: May 25 2012 kl. 3:40 PM

I'm not sure exactly what you're trying to do, but if you're trying to open a file on a user's computer, you can't do that with ordinary web technologies, and that's a really good thing.

If you think about it, what if any web page you went to could modify your configuration files without your permission? Mayhem.

You can allow the user to upload a file, and modify it on the server, but you can't just change a file on the computer's computer.

In fact, you really shouldn't use the file:// mechanism even on your own machine. Use the http:// mechanism or relative references when you can, because this bypasses the whole drive name thing.

When you use http:// you're activating the http mechanism, which only looks for files exposed on web servers.

If you want to investigate uploading a file, take a look at this HTML page:
http://aharrisbooks.net/demo/upload.html
It calls a program called uplaod.php:
http://aharrisbooks.net/demo/upload.php.src.html