hjælp til at skrive uploaded filnavn til DB - Pure ASP Upload
Hej,Jeg har brug for lidt hjælp til at få det rigtige filnavn lagt ind i den rigtige celle i min DB, når filnavnet er blevet lavet om til et unikt navn ved hjælp af Pure APS Upload (HUGE).
Jeg skal have uploaded mellem 1 og 3 filer som kommer fra henholdsvis <input name="doc1">, doc2 og doc3. Pure ASP Upload, uploader dem, og laver et unikt navn til dem, men denne skal jeg have fanget og lagt ind i den rigtige celle i DB, hvordan gør jeg det når min kode ser sådan her ud?
Dim DestinationPath
DestinationPath = Server.mapPath("uploads")
Dim Form: Set Form = New ASPForm %><!--#INCLUDE file="_upload.asp"--><%
Server.ScriptTimeout = 2000
Form.SizeLimit = &HA00000
If Form.State = 0 Then 'Completted
Dim File, DestFileName, fileID
For Each File In Form.Files.Items
If Len(File.FileName) > 0 Then
DestFileName = GetUniqueFileName(File.FileName, DestinationPath)
File.SaveAs DestinationPath & "\" & DestFileName
Response.Write "<br><Font Color=green>File " & File.FileName & _
" was saved to " & DestinationPath & " as " & DestFileName & "</Font>"
End If
Next
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
Dim gFS
Function GetUniqueFileName(FileName, DestPath)
if isempty(gFS) then Set gFS = CreateObject("Scripting.FileSystemObject")
Dim Counter, FullPath, NewFileName, doc
Counter = 1
NewFileName = FileName
if gFS.FileExists(DestPath & "\" & NewFileName) then
Do
Counter = Counter + 1
NewFileName = Counter & "-" & FileName
Loop while gFS.FileExists(DestPath & "\" & NewFileName)
end if
GetUniqueFileName = NewFileName
End Function
Session("fullname") = form("fullname")
Session("address") = form("address")
Session("zip") = form("zip")
Session("city") = form("city")
Session("country") = form("country")
Session("email") = form("email")
Session("doc1") = form("doc1")
Session("doc1") = form("doc2")
Session("doc1") = form("doc3")
if Session("fullname") = "" then
response.redirect "upload.asp?failure=yes"
elseif Session("address") = "" then
response.redirect "upload.asp?failure=yes"
elseif Session("zip") = "" then
response.redirect "upload.asp?failure=yes"
elseif Session("city") = "" then
response.redirect "upload.asp?failure=yes"
elseif Session("country") = "" then
response.redirect "upload.asp?failure=yes"
elseif Session("doc1") = "" then
response.redirect "upload.asp?failure=yes"
else
Dim dbConn
Dim strSql
Dim db_connection
'#Insert the CV
set db_connection = Server.CreateObject("ADODB.Connection")
db_connection.Open Application("ConnectString")
strSql = "Insert into uploadeddoc (fullname, address, zip, city, country, doc1, doc2, doc3, timestamp) VALUES ('" & trim(Session("fullname")) & "','" & trim(Session("address")) & "','" & trim(Session("zip")) & "','" & trim(Session("city")) & "','" & trim(Session("country")) & "','" & trim(Session("doc1")) & "','" & trim(Session("doc2")) & "','" & trim(Session("doc3")) & "','" & now() & "')"
db_connection.execute(strSql)
db_connection.Close
set db_connection = Nothing
Session("fullname") = ""
Session("address") = ""
Session("zip") = ""
Session("city") = ""
Session("country") = ""
Session("phone") = ""
Session("doc1") = ""
Session("doc2") = ""
Session("doc3") = ""
end if
response.Redirect("received.asp")
Jeg håber virkeligt at der er nogen der kan hjælpe mig :-)
/Stig :-)