aspSmartUpload problem
Hej eagleeyeHermed min kode, jeg har kaldt FileField for fileupload, det hedder der også i databasen:
<%@ language="vbscript" codepage="1252" %>
<%
if cstr(Request.QueryString("mode")) = "new" then
Session.Contents("userid") = 0
else
if IsEmpty(Session.Contents("userid")) OR cstr(Session.Contents("userid") & "") = "" then
Server.Transfer "log_image.asp"
end if
end if
Server.Execute "setup.asp"
strConn = Session.Contents("ConnectionString")
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConn
if cstr(Request.Form("Opdater")) <> "" then
SQLBeskrivelse = Replace(Request.Form("Beskrivelse"),"'","''")
if len(SQLBeskrivelse) > 255 then
SQLBeskrivelse = left(SQLBeskrivelse, 255)
end if
if Session.Contents("userid") > 0 then
strSQL = "UPDATE bruger SET"
strSQL = strSQL & " Navn='" & Replace(mySmartUpload.Form("Navn"),"'","''") & "'"
strSQL = strSQL & ", [Password]='" & Replace(mySmartUpload.Form("Password"),"'","''") & "'"
strSQL = strSQL & ", Email='" & Replace(mySmartUpload.Form("Email"),"'","''") & "'"
strSQL = strSQL & ", Country='" & Replace(mySmartUpload.Form("Country"),"'","''") & "'"
strSQL = strSQL & ", fileupload='" & Replace(mySmartUpload.Form("fileupload"),"'","''") & "'"
strSQL = strSQL & ", Kategori='" & mySmartUpload.Form("Kategori") & "'"
strSQL = strSQL & ", Beskrivelse='" & SQLBeskrivelse & "'"
strSQL = strSQL & " WHERE ID=" & Session.Contents("userid")
objConn.Execute strSQL
else
strSQL = "INSERT INTO bruger"
strSQL = strSQL & "(Navn,[Password],Email,Country,fileupload,Kategori,Beskrivelse,OprettetDato) "
strSQL = strSQL & "VALUES("
strSQL = strSQL & "'" & Replace(mySmartUpload.Form("Navn"),"'","''") & "'"
strSQL = strSQL & ",'" & Replace(mySmartUpload.Form("Password"),"'","''") & "'"
strSQL = strSQL & ",'" & Replace(mySmartUpload.Form("Email"),"'","''") & "'"
strSQL = strSQL & ",'" & Replace(mySmartUpload.Form("Country"),"'","''") & "'"
strSQL = strSQL & ",'" & Replace(mySmartUpload.Form("fileupload"),"'","''") &"'"
strSQL = strSQL & ",'" & mySmartUpload.Form("Kategori") & "'"
strSQL = strSQL & ",'" & SQLBeskrivelse & "'"
strSQL = strSQL & ",#" & now & "#"
strSQL = strSQL & ")"
objConn.Execute strSQL
set objRs = objConn.Execute("SELECT @@IDENTITY AS newId")
if not objRs.EOF then
Session.Contents("userid") = cstr(objRs("newId"))
end if
objRs.Close
set objRs = nothing
end if
objConn.Close
set objConn = nothing
Response.Redirect "image.asp"
end if
if cstr(Request.Form("Slet")) <> "" then
strSQL = "DELETE FROM bruger WHERE ID=" & Session.Contents("userid")
objConn.Execute strSQL
objConn.Close
set objConn = nothing
Session.Contents("userid") = Empty
Response.Redirect "image.asp"
end if
if cstr(Request.Form("Logaf")) <> "" then
objConn.Close
set objConn = nothing
Session.Contents("userid") = Empty
Response.Redirect "image.asp"
end if
if Session.Contents("userid") > 0 then
SaveButton = "Update"
strSQL = "SELECT * FROM bruger WHERE ID = " & Session.Contents("userid")
set objRs = objConn.Execute(strSQL)
if not objRs.EOF then
Navn = cstr(objRs("Navn") & "")
Password = cstr(objRs("Password") & "")
Email = cstr(objRs("Email") & "")
Country = cstr(objRs("Country") & "")
fileupload = cstr(objRs("fileupload") & "")
Kategori = cstr(objRs("Kategori") & "")
Beskrivelse = cstr(objRs("Beskrivelse") & "")
end if
objRs.close
objConn.Close
set objRs = nothing
set objConn = nothing
else
SaveButton = "Submit"
end if
strKategorier = "[Select category],,A,A,B,B,C,C"
arrKategorier = Split(strKategorier, ",")
Kategorier = vbCrLf
for idx = 0 to ((ubound(arrKategorier) + 1) / 2) - 1
strKategoriText = arrKategorier(idx * 2)
strKategoriValue = arrKategorier(idx * 2 + 1)
Kategorier = Kategorier & "<option value=""" & strKategoriValue & """"
if strKategoriValue = Kategori then
Kategorier = Kategorier & " SELECTED"
end if
Kategorier = Kategorier & ">" & strKategoriText & vbCrLf
next
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<style type="text/css">
<!--
.style5 {
font-size: 24px;
font-weight: bold;
}
-->
</style>
<head>
<title>Vedligehold brugeroplysninger</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.label { float:left; width:120px; }
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #06275B;
}
a {
font-size: 12px;
color: #06275B;
}
a:link {
text-decoration: underline;
}
a:visited {
text-decoration: underline;
color: #06275B;
}
a:hover {
text-decoration: none;
color: #99CCFF;
}
a:active {
text-decoration: underline;
color: #06275B;
}
.style2 {font-family: Arial, Helvetica, sans-serif}
.style4 {float: left; width: 120px; font-weight: bold; }
</style>
</head>
<body>
<form action="<%=Request.ServerVariables("SCRIPT_NAME")%>" method="post" enctype="multipart/form-data">
<table width="57%" border="1" bordercolor="#99CCFF">
<tr>
<td width="11%" valign="top" bordercolor="#FFFFFF"><span class="style4">Name:</span></td>
<td width="89" colspan="2" bordercolor="#FFFFFF"><input type="text" maxlength="255" name="Navn" value="<%=Navn%>"></td>
</tr>
<tr>
<td valign="top" bordercolor="#FFFFFF"><span class="style4">Password:</span></td>
<td colspan="2" bordercolor="#FFFFFF"><input type="password" maxlength=50" name="Password" value="<%=Password%>"></td>
</tr>
<tr>
<td valign="top" bordercolor="#FFFFFF"><span class="style4">Email:</span></td>
<td colspan="2" bordercolor="#FFFFFF"><input type="text" maxlength=255" name="Email" value="<%=Email%>"></td>
</tr>
<tr>
<td height="26" valign="top" bordercolor="#FFFFFF"><span class="style4">Country:</span></td>
<td colspan="2" bordercolor="#FFFFFF"><input type="text" maxlength="255" name="Country" value="<%=Country%>"></td>
</tr>
<tr>
<td valign="top" bordercolor="#FFFFFF"><span class="style4">Category:</span></td>
<td bordercolor="#FFFFFF"><select name="Kategori" class="style2">
<%=Kategorier%> </select></td>
<td bordercolor="#FFFFFF"><INPUT NAME="fileupload" TYPE="file"></td>
</tr>
<tr>
<td valign="top" bordercolor="#FFFFFF"><span class="style4">Description:</span></td>
<td colspan="2" bordercolor="#FFFFFF"><textarea name="Beskrivelse" cols="50" rows="5"><%=Beskrivelse%></textarea></td>
</tr>
<tr>
<td bordercolor="#FFFFFF"> </td>
<td colspan="2" bordercolor="#FFFFFF"><input name="Opdater" type="submit" class="style4" value="<%=SaveButton%>">
<input name="Slet" type="submit" class="style4" value="Delete"> <input name="Logaf" type="submit" class="style4" value="Logoff"></td>
</tr>
</table>
<p><br>
<span class="label"> </span> <br>
<br>
</p>
</form>
</body>
</html>