Solved

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

Posted on 2004-09-03
14
629 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
  • 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

829 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