Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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
 
Old May 7th, 2006, 07:16 PM
Authorized User
 
Join Date: Sep 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading a file from a server using jscript

I'm getting the path of the file
it exists
and after it exists there's something wrong with my code
any idea of what's wrong?

Code:
<% 
var filePath = Server.MapPath("/work/email-content.txt") 

    var fso = Server.CreateObject("Scripting.FileSystemObject") 

    if(fso.FileExists(filePath)) 
    { 
        var str = ""; 
        Response.Write("File Opened PLEASE"); 
        file = fso.OpenTextFile(filePath,1,false); 
        str += Server.HTMLEncode( file.ReadAll() ); 
        file.Close(); 
        Response.Write(str); 
        //file = Nothing; 
        //fso = Nothing;             
    } 
    else 
    { 
        Response.Write("Didn't open the file"); 
    } 
%>
 
Old May 7th, 2006, 11:22 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tested your code and it worked.
Are you getting any error messages, or is it just that nothing gets written?

However, one side note: in JavaScript you would set the objects to null rather than nothing...
file = Nothing;
would become:
file = null;



Woody Z http://www.learntoprogramnow.com
 
Old May 8th, 2006, 06:22 AM
Authorized User
 
Join Date: Sep 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It breaks when you try to open the file...i guess something's wrong in my server configuration since it worked in yours

 
Old May 8th, 2006, 09:06 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes - it might be permissions on that directory, perhaps?

Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with PHP file reading XML file for output rydog65 Beginning PHP 0 March 26th, 2008 05:13 PM
Can't save XMLDoc to a xml file using JScript induriprakash Javascript 2 May 13th, 2005 02:44 PM
How to save XML file using JScript/DOM in IE induriprakash XML 2 April 26th, 2005 07:37 AM
Help sending XML file to server, reading response bradartigue XML 1 September 5th, 2003 07:42 AM





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