Solved

ASP upload 'An invalid '/' or '\' was found in the Path parameter for the MapPath method'

Posted on 2004-09-03
14
630 Views
Last Modified: 2012-08-14
Every1 - please can you help

I am having problems with an upload script

I have :

(server.mappath("/images/" & response.Write(request("deptid")) & "/" & "thumb"))

It doesnt work, the error is:

An invalid '/' or '\' was found in the Path parameter for the MapPath method.

Why?  How can I resolve it?


0
Comment
Question by:tingleweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
14 Comments
 
LVL 22

Expert Comment

by:neeraj523
ID: 11970776
Hello

try this

<%
Response.Write Server.mapPath("/images/") & "/" & Request("deptid")) & "/thumb"
%>

neeraj523
0
 
LVL 3

Expert Comment

by:Ayesha_K
ID: 11970961
try

server.mappath("/images/" & request("deptid") & "/" & "thumb")

and make sure request("deptid") has some value
0
 

Author Comment

by:tingleweb
ID: 11971474
Guys

Count = Upload.Save(Response.Write Server.mapPath("/images/") & "/" & Request("deptid")) & "/thumb")


and

Count = Upload.Save(server.mappath("/images/" & request("deptid") & "/" & "thumb"))

Both throw the error :
An invalid '/' or '\' was found in the Path parameter for the MapPath method.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:Ayesha_K
ID: 11971572
try

server.mappath("images/" & request("deptid") & "/thumb")

or if the images folder is one level higher than your folder ... then try

server.mappath("../images/" & request("deptid") & "/" & "thumb")
0
 

Author Comment

by:tingleweb
ID: 11971807
mm...still not working

(.. arent allowed in the server.mappath it says)

This works by the way - it is another upload script for the main images directory...

(server.mappath("/images/" & response.Write(request("deptid"))))
0
 
LVL 3

Expert Comment

by:Ayesha_K
ID: 11972077
are you sure there is a thumb directory in the request("deptid") directory ???
0
 

Expert Comment

by:N_F_S
ID: 11972768
 Hi,

 I assume you are using ASPupload component? This is how I would do, you don't need response.write:

Count = Upload.Save (Server.MapPath("images/") & "/" & Request("deptid")) & " & "/" & "thumb")

I  didn't test this, but it should work, let me know

N_F_S
0
 

Expert Comment

by:N_F_S
ID: 11972803

 Yes, as Ayesha_K  said, it seems you want to generate a folder from "deptid" request......make sure the "deptid"(the value from it) folder & thumb folder exists

N_F_S
0
 
LVL 6

Expert Comment

by:masirof
ID: 11973118
Looks like Request("deptid") is empty. Please try tp replace "\" to "/" or vice versa.
0
 
LVL 6

Expert Comment

by:masirof
ID: 11973975
Using REPLACE command
0
 
LVL 11

Expert Comment

by:mouatts
ID: 11975281
If request("deptid") is empty the string being passed to Mappath is "/images//thumb" hence the error message.

(server.mappath("/images/" & response.Write(request("deptid"))))
works because response.write does not resolve to nothing hence the entire string passed to Mapppath is "/images/"

Either check that deptid is not empty and then if ok use

Server.mapPath("/images/") &  Request("deptid") & "/thumb"


or if you are happy to omit the deptid bit when it is empty try adding the following

function NVL2(f,r,nr)
on error resume next

NVL2=nr
IF f=vbNullstring or len(f)<1 or isNull(f) THEN
      NVL2=r
END IF
END FUNCTION


Then use
 
Server.mapPath("/images") &  nvl2(Request("deptid"),"","/"&request("deptid")) & "/thumb")

The NVL2 function tests the first parameter and if null/empty returns the second parameter otherwise returns the third parameter.

HTH
Steve
0
 
LVL 22

Expert Comment

by:neeraj523
ID: 11978851
Hello


Can you tell me the output of this

<%
Response.Write Server.mapPath("/images/") & "/" & response.Write(request("deptid") & "/thumb"
%>

neeraj523
0
 
LVL 11

Accepted Solution

by:
mouatts earned 250 total points
ID: 11979525
Well I don't know what map path will resolve it to but its going to be something like
c:\inetpub\wwwroot\images//1/thumb
assuming that deptid = 1 and that images is under the wwwroot directory. So in my example above I also had the slashes the wrong way round so it should have read

Server.mapPath("/images") &  nvl2(Request("deptid"),"","\"&request("deptid")) & "\thumb")

HTH
Steve
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question