Upload af filer til database via asp-smart-upload
Hejsa.Jeg ved ikke hvad problemet er ?
databasen ser sådan her ud:
tabel:
Filer
Inde i tabellen filer:
ID - autonummer
filnavn
kommentar
fil
--------------------
Her er fil nr. 1:
<form action="2.asp" method="post" name="upload" target="_parent" id="upload">
<table width="90%" border="0">
<tr>
<td width="81">Navn på fil </td>
<td width="254"><input name="filnavn" type="text" id="filnavn"></td>
</tr>
<tr>
<td>Fil</td>
<td><INPUT NAME="fil" TYPE="FILE" id="fil" SIZE="30"></td>
</tr>
<tr>
<td>Kommentar</td>
<td><textarea name="kommentar" cols="30" rows="5" id="textarea2"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Tilføj"></td>
</tr>
</table>
</form>
----
Her er fil nr. 2 som uploder til databasen:
<%
Dim Conn, MyConnection, MySQL, filerRS
Set Conn = Server.CreateObject("ADODB.connection")
Set filerRS = Server.CreateObject("ADODB.Recordset")
MyConnection = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="& Server.MapPath("yp.mdb")
Conn.Open MyConnection
%>
<%
mappe = "/yp/filer/"
' Response.Write (Server.MapPath(mappe))
' Variables
' *********
On Error Resume Next
Dim mySmartUpload
Dim intCount
Dim mappe
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Only allow txt or htm files
' ***************************
mySmartUpload.AllowedFilesList = "mp3,avi,wav"
' DeniedFilesList can also be used :
' Allow all files except exe, bat and asp
' ***************************************
mySmartUpload.DeniedFilesList = "exe,bat,asp,zip"
' Deny physical path
' *******************
' mySmartUpload.DenyPhysicalPath = True
' Only allow files smaller than 50000 bytes
' *****************************************
' mySmartUpload.MaxFileSize = 50000
' Deny upload if the total fila size is greater than 200000 bytes
' ***************************************************************
' mySmartUpload.TotalMaxFileSize = 200000
' Upload
' ******
mySmartUpload.Upload
' Save the files with their original names in a virtual path of the web server
' ****************************************************************************
intCount = mySmartUpload.Save(Server.MapPath(mappe))
' sample with a physical path
' intCount = mySmartUpload.Save("c:\temp\")
' Display the number of files uploaded
' ************************************
' Trap errors
' ***********
If Err Then
Response.Write("<br><br><b>Fejl : </b>" & Err.description)
Else
' Display the number of files uploaded
' ************************************
' Response.Write(intCount & " file(s) uploaded.")
End If
%>
<%
filerRS.open "Filer", Conn, 3,3,2
filerRS.addnew
filerRS("filnavn") = mySmartUpload.Form("filnavn")
filerRS("kommentar") = mySmartUpload.Form("kommentar")
filerRS("fil") = "yp/filer/" & mySmartUpload.Files("fil").FileName & ""
filerRS.update
%>
<div align="center">
<%
response.Write("Filen er nu blevet opdateret!!!")
response.Write(("<BR>"))
%>
Håber i kan hjælpe...
