Passing a variable to server.mappath

Results 1 to 7 of 7

Thread: Passing a variable to server.mappath

  1. #1
    J Guest

    Default Passing a variable to server.mappath

    I am using server.mappath to locate a directory - the method seems to work fine when I am passing it a "text" path (something in quoutes). When I try to pass it a variable that contains the same doesnt see it - i get this error -<BR><BR>Server.MapPath() error &#039;ASP 0171 : 80004005&#039; <BR>Missing Path <BR>/upload.asp, line 27 <BR>The Path parameter must be specified for the MapPath method. <BR><BR>Anyone had this one before?<BR><BR>thanks<BR>

  2. #2
    Join Date
    Dec 1969

    Default Please show code

    show code

  3. #3
    J Guest

    Default Heres the code

    AN = request("AN")<BR><BR>Dim ul <BR>Set ul = New FileUpload<BR><BR><BR>ul.Extensions = Array( ".jpg" )<BR>ul.UploadSize = 100000<BR>ul.UploadDirectory = server.mappath("/cgi-bin/albums/album" & AN)<BR>ul.AllowOverWrite = False<BR><BR>ul.Upload()<BR><BR><BR>Set ul = Nothing<BR><BR><BR>&#039;comments and explanation<BR>&#039;AN is variable that contains a number, like 60 for instance<BR>&#039;AN is passed from a pervious page, taken from a database<BR>&#039;ul is a fileupload class that processes and uploads the file<BR>&#039;so i am attaching the descriptive number AN to my standard file stem - locating a unique folder that has been already created.<BR><BR>through hours of testing, i have found out the server.mappath method will take any parameter, except a variable that contains a number. If you pass it a variable that contains a number, it ignores the number and takes the rest - but then the file path is screwed up. <BR><BR>Can you tell me why Jerrie?<BR><BR>J

  4. #4
    Eddie Campbell Guest

    Default Works for me

    I have just tried this, and it works fine for me (even if the path doesn&#039;t exist. Maybe the problem is with the fileupload class rather than with Server.MapPath<BR><BR>AN = "12"<BR>Response.Write server.mappath("/cgi-bin/albums/album" & AN) <BR><BR>Also does it work if you do this ?<BR>FullPath = "/cgi-bin/albums/album" & AN<BR>ul.UploadDirectory = server.mappath(FullPath)<BR><BR>

  5. #5
    J Guest

    Default RE: Works for me

    Yeah - it will write the server.mappath value fine. But when it actually passes the parameter to the fileupload class, it drops the & AN. The wierd thing is i set AN = "sometext" - it works fine. It only drops my numbers (which are string values).<BR><BR>I tried setting the entire path equal to a variable as well, as you recommended. It still drops the & AN.<BR><BR>eddie - thanks for your help

  6. #6
    J Guest

    Default The real question

    Here is the real question:<BR>How do i make:<BR><BR>server.mappath("/cgi-bin/albums/album" & AN)<BR>(where AN = "60" - for example)<BR><BR>equal to:<BR><BR>server.mappath("/cgi-bin/albums/album60")<BR>(because this works fine)<BR><BR>I would of thought that these were exactly the same, and no way for the code to differentiate them once passed through.<BR><BR>

  7. #7
    Eddie Campbell Guest

    Default Weird

    I have no idea if this will help, but you could try this.<BR><BR>server.mappath(Cstr("/cgi-bin/albums/album" & AN)) <BR><BR>Which will force it to be a string (which it should be anyway).<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts