---
title: "Åtkomst nekad"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/77126-åtkomst-nekad"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Asa"
published: "2003-05-16T07:28:11.000Z"
updated: "2003-05-16T07:47:48.000Z"
replies: 6
views: 282
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/77126-åtkomst-nekad"
---

# Åtkomst nekad

## #1 — Asa, 2003-05-16T07:28Z

Vet inte varför jag får åtkomst nekad när jag ska ladda upp en bild.

```
<!--#include file="../inc/function.asp" -->

<%If Request.QueryString("action") = "upload" Then
Set FSO  = Server.CreateObject("Scripting.FileSystemObject")
Set Mapp = FSO.GetFolder(Server.MapPath("../stuff"))

Set MyDrive = Mapp.subFolders%>

<table cellpadding="3" cellspacing="0" border="0" width="<%=HeadWidth%>" style="border-top:1px solid #375380;border-left:1px solid #375380;border-right:1px solid #375380" bgcolor="#4669A2">
  <form name="pics" method="post" action="default.asp?cat=pics&action=picUpload" enctype="multipart/form-data">
  <tr>
    <td width="100%" bgcolor="#395684"><b>Ladda upp filer</b></td>
  </tr>
</table>
<table width="100%" cellpadding="0" sellspacing="0" border="0" style="border:1px solid #375380" bgcolor="#4669A2">
  <%For x = 1 To strUploads%>
  <tr>
    <td width="18%"><b>Mapp</b><br>
      <select name="mappDir<%=x%>" class="input">
        <option value="../stuff">Stuff<br>
        <%For Each Folder in MyDrive%>
          <option value="../stuff/<%=Folder.Name%>"><%=Folder.Name%><br>
        <%Next%>
      </select>
    </td>
    <td width="82%">
        <b>Bild <%=x%>:</b><br><input type="file" name="file<%=x%>" style="width:90%" class="input"> 
    </td>
  </tr>
  <%Next%>
  <tr>
    <td width="100%" colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td width="100%" colspan="2"><input type="submit" value="Ladda upp bilder" class="input"></td>
  </tr>
  </form>
  <tr>
    <td width="100%" colspan="2">&nbsp;</td>
  </tr>
</table>

<%ElseIf Request.QueryString("action") = "picUpload" Then
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin

For x = 1 To strUploads
  If Not UploadRequest.Item("file" & x).Item("Value") = "" Then
    filepathname = UploadRequest.Item("file" & x).Item("FileName")
    filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
    value    = UploadRequest.Item("file" & x).Item("Value")
    dirMapp  = uploadRequest.Item("mappDir" & x).Item("Value")

      Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
      pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-14
      Set MyFile = ScriptObject.CreateTextFile(Server.mappath(dirMapp & filename))
        For i = 1 to LenB(value)
          MyFile.Write chr(AscB(MidB(value,i,1)))
        Next
      MyFile.Close
  End If
Next

Response.Redirect "default.asp?cat=pics"
End If%>
```

Permalänk: https://www.webforum.nu/p/77126

## #2 — Palle, 2003-05-16T07:30Z

Har du skrivrättigheter på mappen du försöker spara till..?

Permalänk: https://www.webforum.nu/p/1050565

## #3 — Asa, 2003-05-16T07:33Z

Japp, det har jag!

Jag testade att skriva ut i Next Loopen med denna kod

```
    Response.Write filename & "<br>"
    Response.Write dirmapp & "<br>"
    Response.Write "<br>"
```

Står då så här:
DSC00030.JPG
../stuff

image001.jpg
../stuff/Diverse

Permalänk: https://www.webforum.nu/p/1050568

## #4 — PatrikB, 2003-05-16T07:37Z

Fast, att skriva ut ngt på en asp-sida är inte samma sak som att ha skrivrättigheter i mappen. Response.Write "skriver" till browsern. För detta krävs det endast Read som rättighet, dvs du har rätt att läsa och "exekvera" asp-koden i filen min_fil.asp

cya,
PatrikB

Permalänk: https://www.webforum.nu/p/1050573

## #5 — Asa, 2003-05-16T07:41Z

Jag får väl kolla igen då! Kan kanske vara att jag inte har det.

Permalänk: https://www.webforum.nu/p/1050574

## #6 — Asa, 2003-05-16T07:43Z

Det var så, Haha! Men nu fick ni lite uploadkod utan komponent!

functions.asp ser ut så här:

```
<%Sub BuildUploadRequest(RequestBin)
  PosBeg = 1
  PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
  boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
  boundaryPos = InstrB(1,RequestBin,boundary)
  Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
    Dim UploadControl
    Set UploadControl = CreateObject("Scripting.Dictionary")
    Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
    Pos = InstrB(Pos,RequestBin,getByteString("name="))
    PosBeg = Pos+6
    PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
    Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
    PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
    PosBound = InstrB(PosEnd,RequestBin,boundary)
    If PosFile<>0 AND (PosFile<PosBound) Then
      PosBeg = PosFile + 10
      PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
      FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
      UploadControl.Add "FileName", FileName
      Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
      PosBeg = Pos+14
      PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
      ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
      UploadControl.Add "ContentType",ContentType
      PosBeg = PosEnd+4
      PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
      Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
    Else
      Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
      PosBeg = Pos+4
      PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
      Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
    End If
    UploadControl.Add "Value" , Value 
    UploadRequest.Add name, UploadControl 
    BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
  Loop
End Sub

Function getByteString(StringStr)
  For i = 1 to Len(StringStr)
    char = Mid(StringStr,i,1)
    getByteString = getByteString & chrB(AscB(char))
  Next
End Function

Function getString(StringBin)
  getString =""
  For intCount = 1 to LenB(StringBin)
    getString = getString & chr(AscB(MidB(StringBin,intCount,1))) 
  Next
End Function%>
```

Permalänk: https://www.webforum.nu/p/1050576

## #7 — Palle, 2003-05-16T07:47Z

Mr OveRRidE har ett liggandes här på wF. ;)
<http://www.webforum.nu/showthread.php?s=&threadid=45212>

Permalänk: https://www.webforum.nu/p/1050579

---

Tråden på webben: https://www.webforum.nu/amne/asp/77126-åtkomst-nekad
