Hej!
Jeg har et script jeg har redigeret i, for at give en bruger
mulighed for at slette en fil i en mappe.
slet.asp
***************************************
<head>
</head>
<BODY BGCOLOR="white">
<%
' Variables
' *********
Dim oConn
Dim fso
Dim folder
Dim files
Dim strSQL
Dim oRs
' Object creation
' ***************
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set folder = fso.getFolder(Server.MapPath("Upload"))
Set files = folder.files
' Connect to the DB
' *****************
Set oConn = Server.CreateObject("ADODB.Connection")
curDir = Server.MapPath("test.mdb")
oConn.Open "DBQ="& curDir &";Driver={Microsoft Access Driver
(*.mdb)};DriverId=25;FIL=MS Access;"
' Open a recordset
' ****************
strSQL = "select * from person"
Set oRs = Server.CreateObject("ADODB.recordset")
Set oRs.ActiveConnection = oConn
oRs.Source = strSQL
oRs.LockType = 3
oRs.Open
' Select each file
' ****************
For each file In files
' Only if the file exist
' **********************
if not Request.Form("FILENAME") <> file.name Then
fso.deletefile(Server.MapPath("Upload\(" &
Request.Form("FILENAME") & ")"))
' delete the current file from a DB field
' **********************************
oRs.delete
ors("username") = request.Form("username")
oRs("FILENAME") = request.Form("FILENAME")
oRs.Update
end if
next
' Destruction
' ***********
oRs.Close
oConn.Close
Set oRs = Nothing
Set oConn = Nothing
%>
</BODY>
</HTML>
*************************************
Jeg får i midlertid denne fejlmeddelelse når jeg kører scriptet:
Microsoft VBScript runtime error '800a0035'
File not found
/slet.asp, line 45
Hvad gør jeg galt?
--
Vil du lære at kode HTML, XHTML, CSS, SSI, ASP eller ASP.NET?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials