Salve, con un form vorrei fare l'upload di un file fisicamente in una cartella creata sul server e registrare il percorso in un dbase access; ho costruito il form e richiamo la classe con questo code, che però non fa nessuna operazione e non restituisce però nessun errore, qualcuno ha un'idea perchè non funziona?:
codice:<% Dim DestinationPath DestinationPath = Server.mapPath(VirtualFolder) & "\" Dim Form: Set Form = New ASPForm %><% Server.ScriptTimeout = 2000 Form.SizeLimit = &HA00000 if len(Request.QueryString("titolo"))>0 then Form.UploadID = Request.QueryString("titolo") end if If Form.State = 0 Then 'Completted Const VirtualFolder = "UploadFolder" Dim File, DestFileName For Each File In Form.Files.Items If Len(File.FileName) > 0 Then DestFileName = GetUniqueFileName(File.FileName, DestinationPath) File.SaveAs DestinationPath & "\" & DestFileName Response.Write "La procedura ha avuto esito Positivo ! " & " " Response.Write "Il seguente File:<Font Color=red> " & File.FileName & "</Font>" & " é stato regolarmente inviato al server ed i dati in esso contenuti sono stati importati nel Database Nazionale. " '& DestinationPath & " </Font>" & " " 'con questo nome " & DestFileName & "</Font>" & " " End If Next Dim virtDestinationPath virtDestinationPath = "http://" + Request.ServerVariables("SERVER_NAME") _ + GetPath(Request.ServerVariables("SCRIPT_NAME") ) _ + "/" + VirtualFolder + "/" Dim FileField For Each FileField in Form.Files.Items if len(FileField.FileName)> 0 then Dim DestinationFileName DestinationFileName = DestinationPath & FileField.FileName FileField.SaveAs DestinationFileName Dim Conn, RS, oRs, intCount, numRecords intCount=0 DestinationFileName = "UploadFolder/" & Form("File1").FileName Set Conn = GetConnection Set oRs = Server.CreateObject("ADODB.Recordset") oRS.Open "ListFiles", GetConnection, 2, 2 Do Until oRs.Eof oRS.AddNew oRS("percorso") = virtDestinationPath & DestFileName oRS("titolo") = Form("titolo") oRs.Update intCount = intCount + 1 oRs.MoveNext Loop oRs.Close Set oRs = Nothing Conn.Close Set Conn = Nothing end if Next ElseIf Form.State > 10 then Const fsSizeLimit = &HD Select case Form.State case fsSizeLimit: response.write " <Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font> " case else response.write " <Font Color=red>Some form error.</Font> " 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 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 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 Function SplitFileName(FullPath) Dim Pos, PosF PosF = 0 For Pos = Len(FullPath) To 1 Step -1 Select Case Mid(FullPath, Pos, 1) Case ":", "/", "\": PosF = Pos + 1: Pos = 0 End Select Next If PosF = 0 Then PosF = 1 SplitFileName = PosF End Function Function GetPath(FullPath) GetPath = left(FullPath, SplitFileName(FullPath)-1) End Function %>

Rispondi quotando