Solved

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

Posted on 2004-09-03
14
626 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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now