OK upload af billede til folder men skriver ikke til db
Jeg kan simpelthen ikke se hvorfor der ikke skrives til access databasen?jeg sender en querystring ("id") med over til denne side og skal så opdatere databasen alt efter værdien af denne querystring.
Billede gemmes godt nok i mappen men der kommer en :
HTTP 500 - Intern serverfejl
Internet Explorer
jeg har tjekket at internetgæste kontoen (IUSR_pcnavn) har fuld kontrol!
<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"
response.buffer = true
Response.Clear
aid= request.QueryString("id")
key = request.querystring("key")
If key = 1 then
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest(RequestBin)
contentType = UploadRequest.Item("blob").Item("ContentType")
filepathname = UploadRequest.Item("blob").Item("FileName")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
value = UploadRequest.Item("blob").Item("Value")
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(Server.mappath("../gfx/"&filename))
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
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
%>
<!--#include file="../conn/conn_upload.asp"-->
<%
'indsæt i db
'SQL sætning opbygges
Dim strSQL
aid= request.QueryString("id")
strSQL = "Update forside_text Set "
strSQL = strSQL & "strbilledlink='" & filename & "', "
strSQL = strSQL & "strdato=#" & Date() & "#"
strSQL = strSQL & " Where id =" & aid
Conn.Execute(strSQL)
Response.Clear
'Response.Redirect "hvordennuskalsendeshend.asp"
End if
%>
<html>
<head>
<title></title>
<script language="JavaScript">
function SetCookie (name, value) {var argv = SetCookie.arguments;var argc = SetCookie.arguments.length;var expires = (argc > 2) ? argv[2] : null;var path = (argc > 3) ? argv[3] : null;var domain = (argc > 4) ? argv[4] : null;var secure = (argc > 5) ? argv[5] : false;document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "")}
function set_name(form) {var expdate = new Date ();expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
var tekst = form3.y_tekst.value;SetCookie ("tekst", tekst, expdate)
}
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin=0 topmargin=0 marginheight=0 marginwidth=0>
<form METHOD='Post' ENCTYPE='multipart/form-data' ACTION='upload.asp?key=1' id='form3' name='form3' onSubmit="return set_name(this.form);">
<input type="text" name="y_tekst" value=""><br>
<input TYPE="file" NAME="blob" class="input">
<input TYPE="submit" value="UDFØR" NAME="Enter">
</form>
</BODY>
</HTML>
