SoftArtisans.FileUp
Hejsa.Sidder og fusker med at få denne kode til og virke. Problemet er at når den skal uploade til databasen skriver den at en parameter er forkert. Har prøvet med forskellige parameter men den vil bare ikke uploade til min mssql databse. Feltet i databasen er sat til "varBinary"
Nogle der kan have en ide ?
Her er koden:
<%
Set cmFileUp = Server.CreateObject("SoftArtisans.FileUp")
If Request.QueryString("db") = "save" then
Set saveImageRS = Server.CreateObject("ADODB.Recordset")
saveImageRS.Open "Select * From res_image ", cmConnection, 2, 3
saveImageRS.AddNew
saveImageRS.Fields("imageName").Value = cmFileUp.Form("formImageName")
saveImageRS.Fields("imageDesc").Value = cmFileUp.Form("formImageDesc")
saveImageRS.Fields("imageCatId").Value = cmFileUp.Form("formImageCatId")
cmFileUp.Form("formImageFile").SaveasBlob saveImageRS.Fields("ImageBinary").Value
saveImageRS.Update
Response.Write("<h1> Din fil er nu gemt</h1>")
end if
%>
<%
If Request.QueryString("db") = "get" then
Set openImageRS = Server.CreateObject("ADODB.Recordset")
openImageRS.Open "Select * From res_image where imageName = " & Request.QueryString("formImageName"), cmConnection, 2, 2
Response.AddHeader "Content-Disposition", "attachment;filename=testupload.gif"
Response.Write(openImageRS.Fields("ImageBinary").Value)
end if
%>
<% If Request.QueryString("db") = "" then %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Form send image</title>
</head>
<body>
<form enctype="multipart/form-data" action="imagesend.asp?db=save" name="formSendImageDb" method="post">
formImageName: <input name="formImageName" id="formImageName" type="text" /><br /><br />
formImageDesc: <input name="formImageDesc" id="formImageDesc" type="text" /><br /><br />
formImageCatId: <input name="formImageCatId" id="formImageCatId" type="text" /><br /><br />
formImageFile: <input name="formImageFile" id="formImageFile" type="file" /><br /><br />
<input id="Submit1" type="submit" value="submit" />
</form>
<br />
Hent id
<form action="imagesend.asp" name="formGetImageDb" method="get">
formImageName: <input name="formImageName"type="text" /><br /><br />
<input name="db" type="hidden" value="get" />
<input type="submit" value="submit" />
</form>
</body>
</html>
<% End If %>