Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    ASP




Delete File - Server.MapPath Problem


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 Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Delete File From Server
what r things that I have to do to let the client browser to delete a file on the server. I'm running my server on WIN2000 pro, IIS 5.0. I've stored my website and server in a virtual directory. This is the code i use to delete a file from the server folder

Code:

Function delete_file(exceldb)
'***************** Delete**********************
Set fso = CreateObject("Scripting.FileSystemObject")
Set fileObject = fso.GetFile(Server.MapPath("..upload2uploads"& exceldb))

fileObject.Delete
Set fileObject = Nothing
Set fso = Nothing
' Deletes exceldb
End Function

Upload, Email And Delete File Off Server!
I have the setup working close to what I am after. The upload script I am using has been supplied by 'Lewis Moten'.

Basically what I am after is.

A job application contact form. that includes a input="file" element allowing the user to send a CV, to the address related to that job.

So far locally I have the file uploading, the file sent, and then the file deleted all working fine. Althoug this may well work locally I feel I will have problems when I come to trying this live. Mainly due to timings.

Surely the script would need to know when the file has been uploaded completely, also when the file has been sent completely before delete....

HOWTO: Server.MapPath To A Different Server Computer
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:

Server.MapPath
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..

Server.MapPath
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))
%>


Server.MapPath()
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?

Server.mappath.
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?

Server.mappath
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?

Server.Mappath()
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...

Server.MapPath
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.

Server.MapPath
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.

Server.mappath
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?

Anyway To Use MapPath With Server.Execute?
I need to use Server.Execute for dynamic includes. My files are located in different folders and what works for one doesn't work for another. I need to include the full path to the file because relative paths do not work. Can someone tell me how to do something like this:

Server.Execute(Server.MapPath("./") & "includessubnavigationdefault.asp")

I keep getting this error:

Invalid URL form or fully-qualified absolute URL was used. Use relative URLs.

The problem is I NEED to use relative URLs some how.

Server.MapPath Alternative?
I have an asp file that gathers info from a form and sends to the database. im now changing the location of the database from the root path. I think that because of this i cannot use Server.MapPath method of sending data.

Coudl someone please help me out and let me know how i would change the code? Im quite new to this as you could probably see. Code:

Server.mappath Problem
Anyone know how i can add other webserver files using server.mappath?

Server.MapPath Error
I just took up the task of learning ASP, done all the hello world stuff and then thought about the DB side of things and thought that a login system would be a nice place to start, so naturally I started with the registration page, and asp page to do the actual DB stuff, but it would seem I have a prob with Server.MapPath. So I edited my Register page to test and sure enough it doesn’t work, but it works when I make a page with just a .Write of the Server.MapPath Code:

Server.MapPath Error
I have a project where multiple sites in separate folders use the same db. My dbconn include file is causing this error.

Server.MapPath() error 'ASP 0173 : 80004005'

Invalid Path Character

/rboggs/fu/fu021/assign6/includes/dbconn.asp, line 9

An invalid character was specified in the Path parameter for the MapPath method.

here is my code
[hightlight="ASP"]
<%
Dim cnnEXDB

I have no clue what is wrong here any help would be greatly appreciated

Server.Mappath Command
In my root folder, there is a folder "Images". I need to check whether there is a file named 23.jpg in it or not. I am using the following code but it's returning false. The file is in the folder.

<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
x="23.jpg"
If fs.FileExists(Server.Mappath("/Images/"&x)) = true Then
Response.Write("File Exists.")
Else
Response.Write("File Does Not Exists")
End If

set fs=nothing
%>

Server.mappath Method
I need to map a path to my database file automatically, if I move the application to a different direcotry level I still have to write part of the path to get the application to work.

Is there anyway I can translate the directory path and place inside the mappath function so I dont have to manually edit it?

cst = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" &
server.mappath("shopsmartnetworkcartcart.mdb")

MapPath With Server.Execute
I need to use Server.Execute for dynamic includes. My files are located in different folders and what works for one doesn't work for another. I need to include the full path to the file because relative paths do not work. Can someone tell me how to do something like this:

Server.Execute(Server.MapPath("./") & "includessubnavigationdefault.asp")

I keep getting this error:

Invalid URL form or fully-qualified absolute URL was used. Use relative URLs.The problem is I NEED to use relative URLs some how.

Server.mappath() Parent
How to use server.mappath() parent folder correctly:

Server.MapPath("../test.asp")

Changing Server.MapPath
I have just changed host and I need to change my Server.MapPath to comply with my new host db folder . Currently I have my path set to

Server.MapPath("db/access.mdb")

but I need to move it back up a few folders so it is above the "www" folder in the new hosts specified db folder. How do I achieve this?

Passing String To Server.MapPath
How can I pass the results of a form field submitted to this statement
below?

<%
Set MyFileObj = Server.CreateObject("Scripting.FileSystemObject")
'### This Works
'###Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath("body.txt"))
'### This Doesnt work
Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath(" &
request.form("MyFileName") & "))

WHILE NOT MyTextFile.AtEndOfStream
Response.Write(MyTextFile.ReadLine & Chr(10))
WEND
MyTextFile.Close
%>

Server.MapPath Returning Wrong Path
I've got the directory f:CompanyProduct set as web shared so it's got a
virtual directory in the default web site on my test server's IIS. If I try
to use Server.MapPath in that site it returns a path within
c:Inetpubwwwroot rather than the real path.

Can anyone please tell me why this isn't working?

Delete Files Off The Server
Linux Server with Chillisoft ASP.

How would I get an ASP page to delete an image file, probably a .jpg off the server.

Basically, what I want to do, is that when the user deletes a product item from the database, it will also delete the corresponding image file from the images folder. So that the server space doesn't just fill up with redundant image files over time.

If it makes any difference the image files are uploaded using a PHP script, I've no idea how it works, but it does.

Delete Files In Server
I have a Product and that product contains some documents.The documents are uploaded to server and can be viewed in my asp application.

In admin module i have given option to edit or delete that product.In the event of edit just the records in the database get changed.But in the case of delete i have to do 2 things

1. Delete all the data related to that product.
2. Delete all the related documents for that product in the server.

So can anybody help me figure out how to delete a file using asp in ftp server.

Delete File
How can I delete a file which is saved in a folder when the user checked on the checkbox of the file to be removed and click on the Delete button?

Deleting Files From Server... ObjFso Delete
I'm trying to delete files from the server and its not working. Can any one help please?
It says the file doesn't exist... where as the file exists...

I did a response.write for my delFile to make sure its there but it doesn't see the file... Code:

Error Trying To Delete File
I am trying to delete a file off a server (same server asp app is running on). I have done this before and not encountered any problems.

The code I am using is:

Set File = CreateObject("Scripting.FileSystemObject")
ImagePath =
Server.MapPath("......sectionsezineeditionsimagesarticlethu mbs")
ImagePath = ImagePath & "" &
(RS_Content.Fields.Item("CON_Issue_Number").Value) & "" &
(RS_Content.Fields.Item("CON_Image").Value)

However, I am getting an error pointing to the last line of code above:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

I'm sure I am missing something simple from staring at this so long.

Program For Delete File
HI can any body give me a program for delete a online file in asp.
Actually I have created a program for mail attachment. For attaching
the file first of all I have to upload the file in a directory but
after sending attach file the file should be remove from directory.

Delete File Across Network
I need to delete files across the network using web client (IE 6.x) in Win 2003 - IIS 6.0 environment.suggest an approach I can use to acheive this.Will using FSO do the job or I have to go COM way.

FSO Delete The Very Last Character In Tgext File
I am generating a huge CSV file. It is to large to open in notepad.

Can I use the Filesystem Scripting Object to read the very last line of the
file and delete the very last character?

I am hoping the DSO will not have to read thru the whole file. it is probably way to big.

Delete Or Rename A File System
What is the easiest way to 1) delete a File System Website Solution and 2) rename a File System Website solution?

I noticed when I create the ASP.NET Web Site (via File System location option) that I get one directly with my code (.aspx etc files). but the solution is under the default Visual Studio directory. So I assume if I delete these two directories then my solution is really gone?

Renaming a solution seems to be a bit more tricky - what would be the easiest way to rename the solution and the associated directory with the acutal code (.aspx etc files)?

Delete Line From Text File
if I had a form using the input textboxes using username and password. how do I use the .asp language to remove the line from a .txt using the following format:

username<space>password

Prevent My Client To Delete File
We have offer a web space to hosting our client website. We offer them to upload asp files to their web space. How can I prevent the client from uploading asp files that will harm our web server.

For example, deleting files in our server using Scripting.FileSystemObject to delete our systemmfiles.

Delete A Line In Text File Or From An Array
I have an Access DB with newsletter preferences in it. What I am trying to do is select small groups to send a custom newsletter out to. So my localhost criteria web page goes to the Access DB and pulls the email addresses that match my current criteria. I then write that list out to a file (newsletterlist.txt). Maybe that is my problem, but I wanted to do that so if my machine crashed while processing, I would know where to recover it. I had looked at arrays and dictionaries but dictionaries aren't good from what I found for hundreds of entries and arrays I can't keep track of..argh.

Anyways, I then wanted to loop through the file (newsletter.txt) find the next email address, with it I can query back to the DB and get preferences and assemble the email and out the custom newsletter goes.

I've seen where MS says deleting a line using the FileSystemObject is not possible, though wanted to see if anyone has found a work around.

Performance isn't that much of an issue for me, as I figured I'd set the thing to running and go to dinner! So anyone have suggestions - even if it means taking the text info to an array, somehow delete one of the addresses and then put it back to a file...anything that can one by one delete the addresses so I know that it all has worked as there would be no email addresses left in the file.

IIS Delete/write Text File Permissions
ive set the permissions to the folder which the text file is in to 'Write' and 'Read', but i still continue to get:

[/CODE]
Microsoft VBScript runtime error '800a0046'

Permission denied

/modules/admin/program.asp, line 197
[/CODE]

all the path leading to the file is set to allow write aswell.... any ideas why this might be happening?

Copy Or Upload File From Server To Ftp Server
I want to copy or upload a file from server say some lanserver to ftp server through ftp. Is it possible.

Post File From Server To Another Server
I accept a few user inputs and a file from the user, post it to my ASP page.
I'm able to receive the data as well as the file properly in Receiver.asp.
In my receiver.asp, I need to process the user inputs and subsequently POST
this data and the file again to a different server. I would like to use
ServerXMLHttp. Now, how do I simulate Form creation in receiver.asp.

I use the following code to post to the second server
MyXmlHttp.open "post", myTargetURL,false
MyXmlHttp.setRequestHeader "Content-Type", "multipart/form-data"

Now here's where I get stuck.

1) How do I construct the form data? How can I put together the data i
received (which is text) as well as the received file (which is Binary) in
the same Send statement for the Post? -- I assume that if HTML forms do it in
some format, I should be able to simulate the same through ASP, but how???

2) The received file will not be stored anywhere in my server. It has to
be forwarded in memory.

Should it look somewhat like the following?

MyXmlHttp.send ("userId=" & someUserId & "&privateLabelID=" & someLabel &
"&File=" & receivedBinaryFileInMemory)

MapPath()
Is there a built-in function that will give me the full url for a logically mapped address? Basically I want to pass "../folder1/default.asp" from www.mysite.com/folder2/something.asp and have it return "http://www.mysite.com/folder1/default.asp"...anyone know a nice way to do that? I'd like to avoid parsing the string if a function is already build in.

FileSystemObject / MapPath
I have a script:
Set objdFile = Server.CreateObject("Scripting.FileSystemObject")
Set OpendFile = objdFile.OpenTextFile(Server.MapPath("dUpdate.txt"))
dFileValue = OpendFile.ReadLine
OpendFile.Close

And It Returns A:
"File Not Found Error"

The dUpdate.txt file is in the Root. what I am doing wrong?

MapPath Method
I am coping a file from server to local on my computer using:

fso.CopyFile Server.MapPath("downloadworkfile.htm"), Server.MapPath("p:workingworkfile.htm"), true
I am getting MapPath method must be a virtual path. How do I reference a virtual path?

Page 2 - Mappath Error
Server.mappath always returns an absolute disk path to a file, regardless of if you pass a web path that starts from the root of the web or relative to the current directory.

chazukka's example will work fine as long as the script is executed from a page that's in the proper directory, i.e., a page that has subdirectory named database and the mdb file is in that subdirectory.

For example, assuming you're running /myweb/somewhere/myfolder/myasp.asp in a directory /myweb/somewhere/myfolder and the database file is in /myweb/somewhere/myfolder/database/mydb.mdb then

diskp1 = server.mappath("database/mydb.mdb")
diskp2 = server.mappath("/myweb/somewhere/myfolder/database/mydb.mdb")

diskp1 and diskp2 will have identical contents

Error At Map Path System.Mappath()
Error at Map Path System.Mappath()

Please tell me a walk around for system.mappath("../database/data.mdb")

my files are already configured with this path

now windows 2003 server IIS6.0 is not allowing this.

MapPath Error DB Connection Access Database
I seem to be getting this error, and after Googling and searching this site, I still can't get a grip on it. I have a site on a server which is being developed for a national company who will offer this site to their members, hosting each on the national orgainzations servers. I have this string -

openStr = "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & Server.MapPath("../databases/srt.mdb")

Which results in this error:
The '..' characters are not allowed in the Path parameter for the MapPath method

Ok, the common solution seems to be a configuration on the server, which wouldn't be a problem IF the site was to remain where it is. BUT, seeing as I will give this site to the client, who will host it on their servers, could this configuration "fix" be a problem, perhaps for security issues.

Get File From FTP Server
<%
Response.Buffer = True
Set objHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
'objHTTP.open "GET","ftp://xxx.xxx.xx.xxx/xxx.mp3", false, "username",
"password"
objHTTP.open "GET","ftp://username:password@xxx.xxx.xx.xxx/xxx.mp3",
false
objHTTP.send

Response.ContentType = "application/octet-stream"
Response.BinaryWrite ObjHTTP.responseBody
%>

why the above code does not let me access the file on the FTP server? Neither method to authentcate seems to work. Also tried "OPEN" but I don't think that worked either.

Upload A File To The Server?
I have just this morning built a very basic login area for myself.

Now I wish to have a script that will move a file on to the server.

I have tried looking up Google but it seems a bit quiet on tutorials with this.

Can anyone point me in the right direction?

I basically want to be able to upload a file onto the server with an ASP script.

Reading File From Server
Consider the following code snippet:

<%
Dim objFSO,objOpenFile,strPath

strPath=Server.MapPath("ADList1.txt")
Set objFSO=Server.CreateObject("SCRIPTING.FILESYSTEMOBJECT")
Set objOpenFile=objFSO.OpenTextFile(strPath,1)
Do While Not objOpenFile.AtEndOfStream
Response.Write(objOpenFile.ReadLine() & "<br>")
Loop
objOpenFile.Close
Set objOpenFile=Nothing
Set objFSO=Nothing
%>

When I try to execute the above code, the code never gets executed. Neither
am I shown a script timeout error. After a lot of investigations, I
concluded that the code is not getting executed due to the presence of

Set objOpenFile=objFSO.OpenTextFile(strPath,1)

If I comment line nos. 3 to 8, then the code gets executed but as expected
without any output. Is this happening because of some permission which has
not been given to IIS 5.0? If so, what is it? I am working on Windows 2000
Professional.

File Uploading To Server
Can you help me find an asp code that will upload a file from my PC to web server?


Copyright © 2005-08 www.BigResource.com, All rights reserved