Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old January 27th, 2005, 11:49 PM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP - Saving file to folder

I currently have a PDF file that has form fields in it. I have created an asp file that reads in the fields and then spits out a .fdf file. My problem is that when I try specify what folder to save the .fdf file in I get a permission denied error. Here is my code. I'm running IIS on Windows XP Pro. If I remove the & "/batbin" the resulting file is saved to the Inetpub folder. How do I specify a folder under the wwwroot directy or anywhere else for that matter? Also, how do I set security permissions on folders to allow for writing of files?

<%
Folderpath=server.mappath("\") & "/batbin"

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile(Folderpath & Request.Form("Zip") & ".fdf")
a.WriteLine("%FDF-1.2")
a.WriteLine("1 0 obj<</FDF<</Fields[")
  For Each x In Request.Form
    If x = "Submit" Then
    Else
      a.WriteLine("<</T(" & x & ")/V(" & Request.Form(x) & ")>>")
    End If
   Next
a.WriteLine("]")
a.WriteLine(">>>>")
a.WriteLine("endobj")
a.WriteLine("trailer")
a.WriteLine("<</Root 1 0 R>>")
a.WriteLine("%%EOF")
a.Close
Set a=nothing
Set fs=nothing

Response.Write "Thank You"
%>


Thanks
  #2 (permalink)  
Old January 28th, 2005, 06:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think you've just got you're slashes the wrong way around.
/ is the root of the web app
\ separates folders in physical windows paths
so try Folderpath=server.mappath("/") & "\batbin"

also in this line:
Set a = fs.CreateTextFile(Folderpath & Request.Form("Zip") & ".fdf")
make sure you have a \ between the batbin folder name and the file name.

Permissions can be set from Explorer. Just right-click the folder, choose Properties, go to the Security tab and add write permissions for whatever user your asp page is running under.

hth
Phil
  #3 (permalink)  
Old January 28th, 2005, 02:59 PM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Phil

I have changed my code to the following as you suggested.

Folderpath=server.mappath("/") & "\batbin"

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile(Folderpath & "\" & Request.Form("Zip") & ".fdf")

My problem is I am still getting a Permission Denied error. I went to the batbin folder located at C:\Inetpub\wwwroot\batbin via explore and right clicked the folder. I then selected properties. I don't seem to have a security tab. I have general, sharing, web sharing and customize. Any suggestions? I'm running Window XP pro and using IIS.

Thanks

  #4 (permalink)  
Old January 28th, 2005, 03:24 PM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually I just figured this out from another post. In XP pro there is a setting you need to turn off in order to see the security tab in the folders properties. Here is what to do:

Open 'My Computer'. Click 'Tools' and then 'Folder Options'. Then click on the 'View' Tab and scroll all the way to the bottom. Uncheck 'Use Simple File Sharing(Recommended)' and click 'Ok' or 'Yes' to the warning.

Once this is done go to the folder you need access to and right click it and click properties. You will now see a security tab. Click the security tab. You will need to add a new user. The name of the new user is "iusr_(machine_name)". For example if you machine name is billxp then you would type in iusr_billxp. Click ok and then set the access rights for the new user you added. You should now be able to access the folder via an your asp program.


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable saving file in TEMP Folder sandeep.kharat ASP.NET 2.0 Basics 0 April 27th, 2006 12:43 AM
Saving Code behind in another folder Visual Studio ghari ASP.NET 1.0 and 1.1 Basics 1 December 23rd, 2005 10:21 AM
EXCEL question saving a file saving the the first macupryk VS.NET 2002/2003 0 January 6th, 2005 05:33 PM
Help saving a file. mbwegner Beginning VB 6 1 December 20th, 2004 11:26 AM
saving picture from word to other folder DorisTan VB How-To 0 December 3rd, 2004 02:46 AM





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