Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 13th, 2004, 04:07 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default Permission Denied Error

Hi all,

This is my script, I have pointed out the error where my debugger kicks in:

<body>
<form name ="form1">
Customer Name:<br>
<input type ="text" name ="text1"><br>
Customer Surname:<br>
<input type ="text" name ="surname"><br>
Address:<br>
<Textarea name ="Address" rows =5 cols =10></textarea><br>
Telephone Number:<br>
<input type ="text" name ="telno"><br>
Delivery Number:<br>
<input type ="text" name = "delno">
<input type ="button" name ="button1" value ="Post" onclick = "postToFile()">
</form>

function postToFile(){
var filenameIs = "c:\\" + document.form1.delno.value + ".txt"
var TristateFalse = 0;
var ForWriting = 2;

myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
file = myActiveXObject.CreateTextFile(filenameIs);
file = myActiveXObject.GetFile(filenameIs2);
text = file.OpenAsTextStream(ForWriting, TristateFalse);//Permission Denied Here
text.Write(document.form1.text1.value + '\n' + document.form1.surname.value + '\n' + document.form1.Address.value + '\n' + document.form1.telno.value + '\n' + document.form1.delno.value);
text.Close()
}
</script>

What I'm trying to do is create a small text file of information, the filename is created from the variable called 'filenameIs' which gets its value from the field called 'delno'. Any idea why I get permission denied?

cheers
interrupt

__________________
\'sync\' &lt;cr&gt;
The name specified is not recognized as an internal or external command, operable program or batch file.
  #2 (permalink)  
Old October 13th, 2004, 02:19 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

What are the security settings for the zone this site is in?

-Snib <><
Try new FreshView 0.2!
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
  #3 (permalink)  
Old October 14th, 2004, 07:45 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Its within the Trusted Sites.

cheers
interrupt

  #4 (permalink)  
Old October 14th, 2004, 02:02 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

And what are the security settings for Trusted Sites?

-Snib <><
Try new FreshView 0.2!
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
  #5 (permalink)  
Old October 15th, 2004, 05:16 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

All activeX controls are set to 'prompt'.

interrupt

  #6 (permalink)  
Old October 15th, 2004, 05:17 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just to clarify, the text file is actually created but nothing gets written to it, so I just end up with an empty text file.

interrupt

  #7 (permalink)  
Old October 15th, 2004, 05:26 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

On close inspection I now see the problem is that you are trying to access the file twice (or three times). CreateTextFile already returns a textStream object, there's no need to re-acquire it.
Change:
Code:
file = myActiveXObject.CreateTextFile(filenameIs);
file = myActiveXObject.GetFile(filenameIs2);
text = file.OpenAsTextStream(ForWriting, TristateFalse);
to
Code:
var text = myActiveXObject.CreateTextFile(filenameIs); //use a second argument of true to overwrite old file
--

Joe


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting a permission denied error in IE 7 disto Javascript 1 September 20th, 2007 08:26 AM
Error no 70 Permission Denied rupakroy5 Pro VB 6 5 October 7th, 2006 01:26 AM
IE - Runtime error - Permission Denied bstone VB How-To 2 September 11th, 2004 02:21 AM
Permission Denied Error in VBA ebalch24 Access VBA 3 April 12th, 2004 06:51 PM
Error 70: Permission denied junglem@n VB How-To 2 April 3rd, 2004 03:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.