Writing Text File And Server.mappath
I have an application which was successfully writing data from submitted forms to a text file in a directory - in this case:
/data/findata.txt
This was fine because the forms lived at the root level with this directory.
Since then I have added enabled the forms to be used on subdirectories :
/subdirectory/myform.asp
I've used the same code for server.mapparth("data") etc - but instead of locating the directory at the root of the server called "data" it looks to the current directory- doesn't find it and creates another! eek!
What I need is a way to say "right, it doesnt matter what level you are at at the moment, always look at the root level /data directory"...
This has to be fairly dynamic - on the development server here its got a different file structure than on the live server (ie, it lives another level down again on the physical drive)...
Anyone got a good idea on how to look back up?
I do have one way to test which level they are at - but I feel that its a bit 'weak' - I have an ID that tells me if they are working on the upper or lower levels (ie, anything other than 1 is a lower level) - whilst I realise I could use this in the test I'm not sure if its going to be 100% fool proof to base this criteria on this ID.
Therefore I was hoping for a better way using the server.mappath etc...
View Replies
ADVERTISEMENT
the source code is:
<%
Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.OpenTextFile(Server.MapPath("") & "/learn.txt")
mystring=a.readAll
Response.Write ("<pre>" & mystring & "</pre>")
Set a = Nothing
Set fso = Nothing
%>
The output is:
abc
ABC
i don't understand this:
Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.OpenTextFile(Server.MapPath("") & "/learn.txt")
what should be insect in ("Scripting.FileSystemObject")?
and what should be insect in (Server.MapPath("") & "/learn.txt") ?
View Replies
View Related
I found the complete physical path to the doman by Response.Write Server.MapPath(".") and the path is: C:Inetpubwwwrootmyweb"&"gg.txt
With this,there's still error to read my text file.The error source code is place at below,please help me do correction!!! Code:
View Replies
View Related
What's wrong with this code? Thie file is there, why cant it find it?
<%
myfile = request.querystring("filename")
response write myfile
myFSO.DeleteFile(Server.MapPath(" & myfile & "))
SET myFSO = NOTHING
%>
OUTPUT:
data/000000/index.htm
Microsoft VBScript runtime error '800a0035'
File not found
/deletefile.asp, line 9
View Replies
View Related
I am new to working with ASP and I would like to know
the code to create a textfile on the serer and then write
something in it using ASP.
View Replies
View Related
I'm writing data from an access db to a text file then emailing the text file. Everything works fine but it needs to tab deliminated. Can some one post the code for a "tab"?
View Replies
View Related
how to write (String data) to a text file from an ASP page?
View Replies
View Related
Can this be done? For example, in the line below. There may not always be a & objRS("ShippingAddress2") and I'm wondering if there is a way to use an if/then in there some how. If there is no data in that field then I need to pass over this part completely & objRS("ShippingAddress2") & "|"
I'l have several instances where I need to do this Code:
fname.WriteLine("hd2|" & objRS("ShippingName") & "|" & objRS("ShippingAddress") & "|" & objRS("ShippingAddress2") & "|")
View Replies
View Related
i found this piece of code from a site and it claims that you could create a text file into directory "c:test.txt" and writes the line Hello world in it. Code:
View Replies
View Related
I have the following file whatnew.txt on my server! It consists of lines each line hase 3 items seperated by commas like this:
item1,item2,item3
item12,item22,item32
...
...
I need the code to add new items to this file using the browser!
View Replies
View Related
I'm having a hard time to open/write to a txt file from a .asp, the code is right, but, looks that the iis 5.0 is messing with the file system.
once the execution gets to the point of :
Set filetxt = filesys.OpenTextFile(sFilePathAndName, ForReading, False)
the browser just hangs forever, If I do the request to the same .asp several times then the IIS hangs, and can not even stop the service(a bug in IIS). Code:
View Replies
View Related
I'm having a hard time to open/write to a txt file from a .asp, the code is right, but, looks that the iis 5.0 is messing with the file system.
once the execution gets to the point of:
Set filetxt = filesys.OpenTextFile(sFilePathAndName, ForReading, False)
the browser just hangs forever, If I do the request to the same .asp several times then the IIS hangs, and can not even stop the service(a bug in IIS).
I'm running w2k pro, w/IIS 5.0
Here is the code:
View Replies
View Related
Does anyone know if it's possible to write and retrieve variables from a text file??
I know how to use the FSO to create text files and write data to them etc. I just don't know how to write a variable to a text file, and retrieve it at a later date??
I would like similar functionality to a cookie. The reason I can't just use a normal cookie is because the data needs to be permanent and I can't risk the cookies being removed off a users machine.
View Replies
View Related
Here is what I have setup:
- a form that updates a text file.
- for example, in the form I have two fields, title and story. then, this write to a textfile (i.e. theinfo.asp). the update.asp file looks like this:
TSO.write "<%" & vbCrLf
TSO.write "title = """
TSO.write Request.Form("title")
TSO.write """" & vbCrLf
TSO.write "story = """
TSO.write Request.Form("story")
TSO.write """" & vbCrLf
- so, essentially it is creating an asp file with two variables.
- this works fine, it updates the file and i can call these variables in other pages. however, when i call these variables into a form : old versions of the variables populate the form: Code:
View Replies
View Related
i had a vbscript that will read the text file from the bottom to the top, and after reading the file, it will be displayed in the screen, and the code look like this:
PHP Code: Code:
View Replies
View Related
I would like to create a file on the hosting server (if it doesn't exist yet), then I would like to write some error information into it. Finnaly I would like to retreive that information later.
View Replies
View Related
I had to disable Script Blocking, afterwards it worked just fine. HTH Norton Script Blocking cause this problem. the 9o days testing product are finished earlier.
View Replies
View Related
I'm looping through the source code of an HTML page, looking for links, grabbing the source of those links and saving each one in turn to an HTML page on disk.
This is working fine about 70% of the time, but sometimes it falls over when I try to write the source code as a text file to disk: Code:
View Replies
View Related
how to write a text file to a mapped drive or network drive. In my script, I’m currently writing the text file to a local folder on the server temporarily until I can figure this out.
So far I have tried to use the mapped drive letter, network path, etc. to get this working. I believe all the permissions are in order (I hope) as well. No matter what I have tried, I just get a Path Not Found script error. I know this has to be possible, just I’m missing something … probably something right under my nose but I just can’t figure it out.
View Replies
View Related
If I have multiple websites on the same server,can I use the #include directive to reference include files elsewhere on the server? I tried this -
<!--#include file="C:InetpubvhostsATRAMEMBER.COMhttpdocsheader.asp" -->
But no dice...
View Replies
View Related
How do you use server.mappath to update a access database on a completely different computer? One of my websites needs to update a database on a completely different website. Code:
View Replies
View Related
I need to read a simple txt file where there are some variables. I've done
this a lot of times but in this case I have something different: the text
file is located at an ftp server.
The FTP server has anynomous access.
Anyone know how can I do this?
View Replies
View Related
Is there a way to load a text file from a remote server into a string much like using the Inet Control in VB? I am familiar with reading in RSS feeds, but what should I do if the content is a straight text file?
View Replies
View Related
how to creat a page that will allow the user to edit and save a text file on the server.
View Replies
View Related
Set objFile = objFSO.GetFile(Server.MapPath(strFileName))
this line brings up this error:
----------
Error Type:
Microsoft VBScript runtime (0x800A0035)
File not found
/Turbomaster/presupuesto_confirm.asp, line 67
------------
the variable strFileName is being read correctly..
View Replies
View Related
there is an image folder in my root directoty containing images. When I run the following code from a file located in root directory, the file gets deleted. But when I put the file in some other folder, it generates error FILE NOT FOUND.
aND YES, i'VE TRIED BOTH
fso.deletefile(server.mappath("Images/"&photo))
fso.deletefile(server.mappath("/Images/"&photo))
<%
dim fso
photo="902392.jpg"
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.deletefile(server.mappath("Images/"&photo))
%>
View Replies
View Related
I am running exactly the same ASP code on IIS 5.0 and IIS 6.0
I am calling Server.MapPath(), the parameter is a virtual path that includes a reference to a parent path ("Root/Files/../Config/"). 'Config' is a virtual directory under 'Root' which is also a virtual directory. 'Files' is a normal folder.
Under IIS 5.0, the path is correctly mapped to the local path of the 'Config' virtual directory.
Under IIS 6.0, the path gets mapped to "C:WebSiteRootFiles..Config", ignoring the 'Config' virtual directory mapping. Is there a special setting I should be aware of in IIS 6.0 to ensure correct
mapping of virtual paths?
View Replies
View Related
I just don't understand it and I know I must be over complicating things.
strCon= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("diary.mdb")
but then I create a new folder called for instance 'database' and move my diary.mdb into it(with full permissions), what do I change the server.mappath to?
View Replies
View Related
My web site has three folders:
htdocs
logs
private
I want to access an MS Access database in the 'private' directory from scripts within the 'htdocs' folder.
Part of my connection string reads:
Data Source=" & Server.MapPath("../private/test.mdb")
But the page returns the following error:
Could not find file '[my web site]htdocsest.mdb'
Why is it still looking in the 'htdocs' folder when my connection string points to the 'private folder?
View Replies
View Related
The Windows OS allows commas in file/folder names but if you try to call .Code:
Server.MapPath("/smith, john/")
your application will neatly halt and provide you with an error report.Other than telling your site/network users not to use commas as allowed in the OS what can the application designer do to avoid the error.I am sure a kludgey workaround is to scan for the comma, change the file/folder name to something safe then restore the name at the end. I don't think this is a safe way to do things though.
View Replies
View Related
Code:
<%=Server.MapPath(rsCurrImgs("nvcLinkPath"))%>
Gives a strange error. When I do it like this: rsCurrImgs("nvcLinkPath")it works fine. What can it be?
Quote: Error Source: NULL
Category: Server.MapPath()
Description: Invalid Path Character
Full Description: An invalid character was specified in the Path parameter for the MapPath method.
View Replies
View Related
if you have an address
/dir/wwwroot/andy
and you use
server.mappath("/dir/andy")
you recieve the physical path , i.e. c:.inetpub/wwwroot/dir/andy
is there a way of going the other way ie from a physical path to a virtual path?
View Replies
View Related
I'm trying to create a log file of users accessing my site. This I can do on the current server using server.mappath, but I can't figure out how to write to a file on a different server.
View Replies
View Related