Hej på er, har upptäckt ett litet fel.
Jag har en sida med ett par fält, "rubrik", " bild" och "inlägg".
Då man inte väljer någon bild i "bild"-fältet får jag felmeddelande.
Använder denna kod:
<%
Response.Expires=0
Response.Buffer = TRUE
Response.Clear
'Response.BinaryWrite(Request.BinaryRead(Request.TotalBytes))
byteCount = Request.TotalBytes
'Response.BinaryWrite(Request.BinaryRead(varByteCount))
RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
'Exempel på hur man kan 'plocka ner' andra forumlärelement
rubrik = UploadRequest.Item("rubrik").Item("Value")
inlagg = UploadRequest.Item("inlagg").Item("Value")
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")
'Create FileSytemObject Component
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
'Create and Write to a File
pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-14
' Set MyFile = ScriptObject.CreateTextFile(Left(Server.mappath(Request.ServerVariables("PATH_INFO")),pathEnd)&filename)
Set MyFile = ScriptObject.CreateTextFile(Server.MapPath("upload/"&filename))
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
%>
<%
Set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open "Provider=Microsoft.Jet.OLEDB.4.0; "&_
"Data Source="&Server.MapPath("/")
SQLStmt = "INSERT INTO nyheter_u (nyh_bild, rubrik, inlagg, forfattare) "
SQLStmt = SQLStmt & "VALUES('" & filename & "', '" & rubrik & "', '" & inlagg & "', '" & Session("Namn") & "') "
Set RS = Connection.Execute(SQLStmt)
response.Redirect("u.asp")
Connection.Close
Set Connection = Nothing
%>
<!--#include file="upload.asp"-->
