kun fil navn
Hvordan får man denne kode til ikke at skrive den fulde sti ind i "DestFileName" men kun fil navn ?----------------------------------
<%
'Sample file Field-SaveAs.asp
'Store extra upload info to a database
' and file contents to the disk
Server.ScriptTimeout = 5000
'Create upload form
Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
Server.ScriptTimeout = 1000
Form.SizeLimit = 99999*1024'10MB
'was the Form successfully received?
Const fsCompletted = 0
If Form.State = fsCompletted Then 'Completted
'Create destination path+filename for the source file.
Dim DestinationPath, DestinationFileName
DestinationPath = Server.mapPath("UploadFolder")
DestinationFileName = DestinationPath & "\" & Form("SourceFile").FileName
'Open recordset to store uploaded data
Dim RS: Set RS = OpenUploadRS
'Store extra info about upload to database
RS.AddNew
RS("UploadDT") = Now()
RS("Description") = Form.Texts("Description")
RS("SourceFileName") = Form("SourceFile").FilePath
RS("DestFileName") = DestinationFileName
RS("DataSize") = Form("SourceFile").Length
'...
RS.Update
Response.write "<br>Din fil er uploadet"
Dim Field: For Each Field in Form.Files
' Response.write "<br> " & Field.FileName
Next
'{b}Save file to the destination
Form("SourceFile").SaveAs DestinationFileName
'{/b}
' response.write "<Font color=green><br>SourceFile was saved as " & DestinationFileName
' response.write "<br>See ListFiles table in " & Server.MapPath("upload.mdb") & " database.</Font>"
ElseIf Form.State > 10 then
Const fsSizeLimit = &HD
Select case Form.State
case fsSizeLimit: response.write "<br><Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font><br>"
case else response.write "<br><Font Color=red>Some form error.</Font><br>"
end Select
End If'Form.State = 0 then
Function OpenUploadRS()
Dim RS : Set RS = CreateObject("ADODB.Recordset")
'Open dynamic recordset, table Upload
RS.Open "ListFiles", GetConnection, 2, 2
Set OpenUploadRS = RS
end Function
Function GetConnection()
dim Conn: Set Conn = CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.open "Data Source=" & Server.MapPath("upload.mdb")
set GetConnection = Conn
end function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<TITLE>Upload filer</TITLE>
<STYLE TYPE="text/css"><!--TD {font-family:Arial,Helvetica,sans-serif }TH {font-family:Arial,Helvetica,sans-serif }TABLE {font-size:10pt;font-family:Arial,Helvetica,sans-serif }--></STYLE>
<meta name="robots" content="noindex,nofollow">
</HEAD>
<BODY BGColor=white>
<Div style=width:600>
<TABLE cellSpacing=1 cellPadding=3 bordercolor=silver bgcolor=GAINSBORO width="" border=1>
<form method=post ENCTYPE="multipart/form-data">
<TR>
<TD> </TD>
<TD Align=Right><input type="submit" Name="Action" value="Upload>>"></TD>
</TR>
<TR>
<TD>Fil</TD>
<TD><input type="file" name="SourceFile"></TD>
</TR>
<TR>
<TD>Beskrivelse</TD>
<TD><textarea cols="60" rows="8" name="Description"></textarea></TD>
</TR>
</form></Table>
</Div>
</BODY></HTML>
