Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #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.
Reply With Quote
  #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 ;)
Reply With Quote
  #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

Reply With Quote
  #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 ;)
Reply With Quote
  #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

Reply With Quote
  #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

Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 02:42 AM



All times are GMT -4. The time now is 06:32 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.