Hej,
jag andvänder denna kod som är en aning slarvig men du kanske kan hitta nått. Den fungerar iaf.
---------------------
<%
Dim Connect, RS, Addstmt, SQLMAX, MaxFileName, filenamex, item, value
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& dbpath &""
Set RS = Server.CreateObject("ADODB.Recordset")
SQLMAX = "SELECT * FROM table01 WHERE unifilename = (SELECT MAX(unifilename) FROM table01)"
RS.Open SQLMAX, Connect, adOpenStatic, adLockOptimistic
If RS.EOF AND RS.BOF THEN
MaxFileName = 1
Response.write("EOF AND BOF")
Else
MaxFileName = RS("unifilename") + 1
Response.write("found ...<BR>")
End If
RS.Close
' Variables
' *********
Dim mySmartUpload
Dim intCount
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Only allow PDF files
' ***************************
mySmartUpload.AllowedFilesList = "pdf"
' Upload
' ******
mySmartUpload.Upload
' Save the files with their original names in a virtual path of the web server
' ****************************************************************************
intCount = mySmartUpload.Save("D:\inetpub\wwwroot\crs\salesreports\movingdir")
' sample with a physical path
' intCount = mySmartUpload.Save("/someshit")
' Display the number of files uploaded
' ************************************
Response.Write(intCount & " file(s) uploaded.")
' Informations about files
' ************************
Response.Write("Number of files =" & mySmartUpload.Files.count &"<BR>")
Response.Write("Total bytes of files =" & mySmartUpload.Files.TotalBytes &"<BR>")
' Select each file
' ****************
For each file In mySmartUpload.Files
Response.Write(file.FileName & " (" & file.Size & "bytes)<BR>")
filenamex = file.filename
Next
' FORM Collection
' **************
Set RS = Server.CreateObject("ADODB.Recordset")
Addstmt = "SELECT * FROM table01"
RS.Open Addstmt, Connect, adOpenStatic, adLockOptimistic
RS.AddNew
RS("unifilename") = MaxFileName
RS("MyDate") = Date
' Select each item
' ****************
For each item In mySmartUpload.Form
' Select each value of the current item
' *************************************
For each value In mySmartUpload.Form(item)
RS("" & item & "") = value
Next
Next
RS.Update
RS.Close
Connect.Close
Dim fso, file
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.GetFile("D:\inetpub\wwwroot\crs\salesreports\movingdir\"& filenamex &"")
file.Move ("D:\inetpub\wwwroot\crs\salesreports\database\img\"& MaxFileName &".pdf")
%>
<% = MaxFileName %>
//Martin
------------------
?
