<%
Response.Buffer = True
Response.Expires = -1500
Response.AddHeader "Pragma", "no-cache"
Response.AddHeader "cache-control", "no-store"
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("Annons.mdb")&""
Set RecSet = Server.CreateObject("ADODB.Recordset")
Addera = "Select * From Annonser where AnnonsID="&session("AnnonsID")
RecSet.Open Addera, Connect, 3, 3
%>
<%
Function FileUpload(strPath, intMaxSize, arrAcceptType, arrAcceptExt, ByRef strContentType, ByRef strFilename, ByRef intFileTotalBytes)
Dim intPostTotalBytes, intStartPos, intEndPos, i
Dim bstrPostData, bstrDivider
Dim strTemp, strFileSpec
Dim arrSplit
Dim vbCrLfB
Dim bolStopLoop, bolContentTypeOK, bolExtOK
Dim fs, ts, f
strContentType = ""
strFilename = ""
intFileTotalBytes = 0
If Request.querystring("laddaupp") = "ja" Then
vbCrLfB = ChrB(13) & ChrB(10)
intPostTotalBytes = Request.TotalBytes
bstrPostData = Request.BinaryRead(intPostTotalBytes)
If LenB(bstrPostData) <> intPostTotalBytes Then
FileUpload = 1
Exit Function
End If
bstrDivider = LeftB(bstrPostData, InStrB(bstrPostData, vbCrLfB) + 1)
intStartPos = 1
bolStopLoop = False
Do
intStartPos = InStrB(intStartPos, bstrPostData, bstrDivider) + LenB(bstrDivider)
If intStartPos = 0 Then
FileUpload = 2
Exit Function
End If
intEndPos = InStrB(intStartPos, bstrPostData, bstrDivider)
If intEndPos = 0 Then
FileUpload = 2
Exit Function
End If
strTemp = bin2str(MidB(bstrPostData, intStartPos, InStrB(intStartPos, bstrPostData, vbCrLfB) - intStartPos))
If InStr(LCase(strTemp), "name=""bild""") > 0 Then
bolStopLoop = True
Else
intStartPos = intEndPos
End If
Loop Until bolStopLoop
intStartPos = intStartPos + Len(strTemp) + 2
arrSplit = Split(strTemp, ";")
strTemp = ""
For i = 0 To UBound(arrSplit)
If LCase(Left(Trim(arrSplit(i)), 9)) = "filename=" Then
strTemp = Trim(arrSplit(i))
Exit For
End If
Next
If strTemp = "" Or strTemp = "filename=""""" Then
FileUpload = 3
Exit Function
End If
arrSplit = Split(strTemp, """")
strTemp = arrSplit(UBound(arrSplit) - 1)
arrSplit = Split(strTemp, "\")
strFilename = arrSplit(UBound(arrSplit))
strFileSpec = Server.MapPath(LCase(strPath &recset("AnnonsID")&"_0"&recset("AnnonsID")& Replace(fix(recset("datum")),"-","")+696969&"."&right(strFilename,3)))
strTemp = bin2str(MidB(bstrPostData, intStartPos, InStrB(intStartPos, bstrPostData, vbCrLfB) - intStartPos))
intStartPos = intStartPos + Len(strTemp) + 2
arrSplit = Split(strTemp, " ")
strContentType = arrSplit(UBound(arrSplit))
bolContentTypeOK = False
If arrAcceptType(LBound(arrAcceptType)) <> "" Then
For Each strTemp In arrAcceptType
If strContentType = strTemp Then
bolContentTypeOK = True
End If
Next
If Not bolContentTypeOK Then
FileUpload = 4
Exit Function
End If
End If
bolExtOK = False
If arrAcceptExt(LBound(arrAcceptExt)) <> "" Then
For Each strTemp In arrAcceptExt
If LCase(Right(strFilename, Len(strTemp))) = strTemp Then
bolExtOK = True
End If
Next
If Not bolExtOK Then
FileUpload = 5
Exit Function
End If
End If
intStartPos = intStartPos + 2
intEndPos = intEndPos - 2
intFileTotalBytes = intEndPos - intStartPos
If intMaxSize > 0 Then
If intFileTotalBytes > intMaxSize Then
FileUpload = 6
Exit Function
End If
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.CreateTextFile(strFileSpec, True)
For i = intStartPos To intEndPos - 1
ts.Write(Chr(AscB(MidB(bstrPostData, i, 1))))
Next
ts.Close
Set f = fs.GetFile(strFileSpec)
If f.Size <> intFileTotalBytes Then
FileUpload = 7
Exit Function
End If
FileUpload = 0
End If
End Function
Function bin2str(bstrBinary)
Dim i
For i = 1 To LenB(bstrBinary)
bin2str = bin2str & Chr(AscB(MidB(bstrBinary, i, 1)))
Next
End Function
%>
<body topmargin="0" leftmargin="0" link="#000000" vlink="#000000" alink="#000000">
<table cellSpacing="0" cellPadding="7" width="100%" border="0">
<tr>
<td class="verdana2">Lägg till en bild på din pryl om så önskas. <br>
<br>
</td>
</tr>
<tr>
<td class="verdana2">
<form method="POST" enctype="multipart/form-data" action="andra_ta_bort_bild.asp?laddaupp=ja">
<input style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; FONT-SIZE: xx-small; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid; FONT-FAMILY: verdana; HEIGHT: 20px; BACKGROUND-COLOR: whitesmoke" type="file" size="50" name="bild"></p>
<input style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: xx-small; BORDER-BOTTOM-WIDTH: 1px; WIDTH: 100px; CURSOR: hand; FONT-FAMILY: verdana; BORDER-RIGHT-WIDTH: 1px" type="submit" value="Ladda upp bild" name="submitbild"></p>
</form>
</td>
</tr>
<tr>
<td class="verdana2">
<br>
</td>
</tr>
</table>
<table cellSpacing="0" cellPadding="7" width="100%" border="0">
<tr>
<td class="verdana2"><center><%if not recset("bild") = "" then%>
<p>Din nuvarande bild:<br>
<br>
<img src="bilder/<%=recset("bild")%>"> <br>
<br>
<input type="button" style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: xx-small; BORDER-BOTTOM-WIDTH: 1px; WIDTH: 80px; CURSOR: hand; FONT-FAMILY: verdana; BORDER-RIGHT-WIDTH: 1px" onclick="self.location.href='andra_ta_bort_bild_nu.asp?AnnonsID=<%=Recset("AnnonsID")%>&Losenord=<%=recset("Losenord")%>'"value="Ta bort bild" name="tabortbild" size="20">
<br>
<br>
<br>
</p><%end if%>
</center></td>
</tr>
<tr>
<td align="right">
<input style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: xx-small; BORDER-BOTTOM-WIDTH: 1px; WIDTH: 50px; CURSOR: hand; FONT-FAMILY: verdana; BORDER-RIGHT-WIDTH: 1px" onclick="javascript:window.close();" type="button" value="Stäng" name="close"></td>
</tr>
</table>
<%
if request.querystring("laddaupp") = "ja" then
Dim intFileUpload, strContentType, strFilename, intFileTotalBytes
intFileUpload = FileUpload("Bilder/", 200000, Array("image/gif", "image/jpeg", "image/pjpeg"), Array("gif", "jpg"), strContentType, strFilename, intFileTotalBytes)
If intFileUpload = 0 Then
Response.Write "Filen " & strFilename & " blev uppladat.\<BR\>"
recset("Bild") = recset("AnnonsID")&"\_0"&recset("AnnonsID")& Replace(fix(recset("datum")),"-","")+696969&"."&right(strFilename,3)
recset.update
response.redirect "andra_ta_bort_bild.asp"
Else
Response.Write "Det uppstod ett fel under uppladdningen!<BR>"
Response.Write "Fel nummer: " & intFileUpload & "<BR>"
Response.Write "Filnamn: " & strFilename & "<BR>"
Response.Write "Filtyp: " & strContentType & "<BR>"
Response.Write "Filstorlek: " & intFileTotalBytes & "<BR>"
End If
End If
%>
<%
connect.close
set connect = nothing
%>