Ret i post inkl. aspsmartupload.........
Har siddet og bøvlet med dette script længe nu. Jeg har en side hvorfra man kan uploade et billede + tekst. Nu har jeg lavet en side hvor man kan rette i nyheden, det er også ok. Men når man så skal gemme ændringerne og et nyt billede går det galt.Billedet bliver ikke gemt i databasen (i mappe), kun navnet. Nogem som kan hjælpe (sorry ...fylder meget).Ret_i_news.asp :
----------------------------------------------------
<%
Set Conn = Server.CreateObject(\"ADODB.Connection\")
Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"data/news.mdb\")
SQLstmt = \"SELECT * FROM news WHERE id = \" & Request(\"id\")
Conn.Execute (SQLstmt)
Set rs = conn.Execute(SQLstmt)
%>
<form method=\"POST\" action=\"gem_ret_news.asp?id=<%=rs(\"id\")%>\" name=\"form0\" enctype=\"multipart/form-data\">
<!-- enctype=\"multipart/form-data\" skal med ellers virker det ikke -->
<table BGCOLOR=\"#cccccc\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\" leftmargin=\"0\" Cellpadding=\"0\" Cellspacing=\"0\" Border=\"0\" Width=\"780\" HEIGHT=\"100% valign=\"center\" align=center>
<TR>
<TD BGCOLOR=\"#cccccc\" WIDTH=780 align=\"center\" valign=\"top\">
<table BGCOLOR=\"#ffffff\" width=\"780\" border=\"0\" Cellpadding=\"5\" Cellspacing=\"5\" ><FONT FACE=\"Verdana,Arial,Helvetica\" SIZE=\"4\" COLOR=\"#ffffff\"><center><img SRC=\"images/news/top.jpg\" WIDTH=\"780\" HEIGHT=\"75\" BORDER=\"0\"></center>
<tr><td width=\"780\"></td></tr>
<tr><td width=\"780\"><FONT FACE=\"Verdana,Arial,Helvetica\" SIZE=\"1\" COLOR=\"#ffffff\"><img SRC=\"images/news/menu.gif\" BORDER=\"0\"> <!-1-><A Href=\"upload.asp\"><FONT COLOR=\"#000000\"><b>Indryk nyhed</b> </A> <FONT COLOR=\"#666666\">|
<!-2-><A Href=\"vis_redi.asp\"> Ret en nyhed </A><FONT COLOR=\"#666666\">|
<!-4-><A Href=\"vis_slet.asp\"> Slet en nyhed </A><FONT COLOR=\"#666666\">|<A Href=\"system.asp\"> Forside </A><FONT COLOR=\"#666666\"></td></tr>
<tr><td width=\"780\" BGCOLOR=\"#6699CC\"><FONT FACE=\"Verdana,Arial,Helvetica\" SIZE=\"2\" COLOR=\"#ffffff\"><img SRC=\"images/news/pkt1.gif\" BORDER=\"0\"> <b>Nyheds dato:</b> </font><FONT FACE=\"Verdana,Arial,Helvetica\" SIZE=\"1\" COLOR=\"#000000\"></td></tr>
<tr><td width=\"780\"><input type\"text\" style=\"font-family: Verdana\" style=\"font-size:12px;\" SIZE=\"25\" name=\"dato\" value=\"<%=rs(\"dato\")%>\"\"></td></tr>
<tr><td width=\"780\" BGCOLOR=\"#6699CC\"><FONT FACE=\"Verdana,Arial,Helvetica\" SIZE=\"2\" COLOR=\"#ffffff\"><b>Indtast overskrift til nyheden: </font></b><FONT FACE=\"Verdana,Arial,Helvetica\" SIZE=\"1\" COLOR=\"#000000\">( Der kan Max. indtastes 28 anslag)</td></tr>
<tr><td width=\"780\"><input type=\"text\" style=\"font-family: Verdana\" style=\"font-size:12px;\" name=\"headline\" size=\"60\" maxlength=\"28\" value=\"<%=rs(\"headline\")%>\"></td></tr>
<tr><td width=\"780\" BGCOLOR=\"#6699CC\"><FONT FACE=\"Verdana,Arial,Helvetica\" SIZE=\"2\" COLOR=\"#ffffff\"><img SRC=\"images/news/pkt3.gif\" BORDER=\"0\"> <b>Vælg billede til nyheden: </b><FONT FACE=\"Verdana,Arial,Helvetica\" SIZE=\"1\" COLOR=\"#000000\"></b></td>
<tr><td width=\"780\"><input type=\"file\" size=\"50\" style=\"font-family: Verdana\" style=\"font-size:12px;\" name=\"file1\" value=\"<%=rs(\"billed\")%>\"></td></tr>
<tr><td width=\"780\" BGCOLOR=\"#6699CC\"><FONT FACE=\"Verdana,Arial,Helvetica\" SIZE=\"2\" COLOR=\"#ffffff\"><img SRC=\"images/news/pkt4.gif\" BORDER=\"0\"> <b>Indtast nyhed her:</b></font>
</td></tr>
<tr><td width=\"780\"><textarea maxlength=\"20\" style=\"overflow:hidden;\" name=\"News1\" cols=\"110\" rows=\"15\" style=\"font-family: Verdana;\" style=\"font-size:12px;\" value=\"\"><%=rs(\"news1\")%></textarea></td></tr>
<tr><td width=\"780\" align=\"right\"><input type=\"image\" src=\"/images/main/nsco_search.gif\" name=\"submit\" border=\"0\"></td></tr>
</table>
</form>
Gem_news.asp:
---------------------------------------------------
<% @Language=\"VBScript\" %>
<% Option Explicit %>
<!-- #include file=\"style/Adovbs.inc\" -->
<HTML> <body bgcolor=\"#cccccc\" topmargin=\"0\" leftmargin=\"0\" >
<table BGCOLOR=\"#cccccc\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\" leftmargin=\"0\" Cellpadding=\"0\" Cellspacing=\"0\" Border=\"0\" Width=\"780\" HEIGHT=\"100% valign=\"center\" align=center>
<TD BGCOLOR=\"#cccccc\" WIDTH=780 align=\"center\" valign=\"center\">
<table BGCOLOR=\"#cccccc\" width=\"780\" border=\"0\"><FONT FACE=\"Verdana,Arial,Helvetica\" SIZE=\"4\" COLOR=\"#CC0000\"><hr>Der forekom en fejl !<hr><br>
<%
On Error Resume Next
\' Variabler til upload af filer
Dim mySmartUpload
Dim intCount
Dim item
Dim value
Dim file
\' Variabler til databaseoperationer
Dim cn
Dim strSQL
Dim rs
\' Variabler til postsættene
Dim bytKarak
Dim strHeadline
Dim strDato
Dim strNews1
Dim strFil
Dim i
\' Her erklæres/instantieres aspSmartUpload objektet
Set mySmartUpload = Server.CreateObject(\"aspSmartUpload.SmartUpload\")
\'********** Nedenstående fil-extensions accepteres: *************************************
mySmartUpload.AllowedFilesList = \"jpg,gif,jpeg\"
\' Allow all files except exe,txt,bat and asp
\' ***************************************
mySmartUpload.DeniedFilesList = \"exe,bat,asp,txt\"
\' Only allow files smaller than 50000 bytes
\' *****************************************
mySmartUpload.MaxFileSize = 50000
mySmartUpload.Upload
\' Her fanges dataene fra formularen på siden default.asp
\' Læg mærke til, at man ikke kan benytte Request.Form, men skal benytte mySmartUpload.Form
\'bytKarak = mySmartUpload.Form(\"karakter\")
strHeadline = mySmartUpload.Form(\"Headline\")
strDato = mySmartUpload.Form(\"Dato\")
strNews1 = mySmartUpload.Form(\"News1\")
\'Upload af filer
\'Rettighederne på mappen for IUSR skal være RW
intCount = mySmartUpload.Save(\"images\")
\'Derefter gemmes alt i databasen NEWS
Set cn = Server.CreateObject(\"ADODB.Connection\")
cn.Open \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & Server.MapPath(\"data/NEWS.mdb\")
For i = 1 To mySmartUpload.Files.Count
If mySmartUpload.Files.Item(i).FileName = \"\" Then
Else
strFil = mySmartUpload.Files.Item(i).FileName
strSQL = \"UPDATE DISTINCTROW news SET Headline = \'\" & request.form(\"Headline\") & \"\', dato = \'\" & request.form(\"dato\") & \"\', news1 = \'\" & request.form(\"news1\") & \"\' WHERE id = \" & Request(\"id\")
\'strSQL = strSQL & \"VALUES(\'\" & strHeadline & \"\',\'\" & strDato & \"\',\'\" & strNews1
strSQL = strSQL & \"\',\'\" & strFil & \"\');\"
response.write sqlstmt
Conn.Execute (SQLstmt)
End If
Next
\' Trap errors
\' ***********
If Err Then
Response.Write(\"<TR><TD><FONT FACE=\'Arial, helvetica\' SIZE=2 COLOR=\'#000000\'><b>Fejl Nr. \" &Err.Number &\":</b> \" &Err.Description & \"<BR><BR></TD></TR>\")
Response.Write(\"<TR><TD><FONT FACE=\'Arial, helvetica\' SIZE=2 COLOR=\'#000000\'><b><hr>De har sikkert forsøgt at uploade en filtype, der ikke accepteres!<hr></b></TD></TR>\")
Response.Write(\"<TR><TD><FONT FACE=\'Arial, helvetica\' SIZE=2 COLOR=\'#000000\'><BR>Kun billedfiler af typerne \'billede.gif\', \'billede.jpg\' eller \'billede.jpeg\' accepteres.<BR><BR></TD></TR>\")
Response.Write(\"<TR><TD><FONT FACE=\'Arial, helvetica\' SIZE=2 COLOR=\'#000000\'><b><hr>Husk billedet kun må fylde max. 50 Kb!<hr><BR><BR><input type=\'button\' value=\'<< Prøv igen\' onClick=\'history.go(-1)\'></b></TD></TR>\")
Else
conn.Close
Set conn = nothing
Set SQLstmt = nothing
Response.Redirect(\"next.htm\")
End If
%>
</table></form></td></tr></TABLE></body></html>