Salve a tutti, premetto che so ben poco di asp, anzi quasi nulla.
Ho un piccolo problema, anzi due....ma procediamo solo con il primo per ora....
Devo fare un upload di un file, non mi importa l'estensione, file di testo più precisamente un CV, ho scaricato questo script:
http://asp.html.it/script/vedi/3701/upload-senza-com/
metto tutti i miei file nel server...faccio le prove, mi dice che il file è stato uppato, ma non lo vedo da nessuna parte....
Qualche anima pia mi può aiutare???
grazie.
vi posto anche il codice dei file
todatabase.asp
<%
Dim oUpload
Dim oField
Dim oConn
Dim oRs
Dim sSQL
Dim sFileName
Set oUpload = New clsUpload
Set oFile = oUpload("File1")
' parse the file name
sFileName = oFile.FileName
If Not InStr(sFileName, "\") = 0 Then
sFileName = Mid(sFileName, InStrRev(sFileName, "\") + 1)
End If
Set oConn = Server.CreateObject("ADODB.Connection")
Set oRs = Server.CreateObject("ADODB.Recordset")
oConn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("./") & "\Upload.mdb"
sSQL = "SELECT FileID, FileName, FileSize, ContentType, BinaryData FROM Files WHERE 1=2"
oRs.Open sSQL, oConn, 3, 3
oRs.AddNew
oRs.Fields("FileName") = sFileName
oRs.Fields("FileSize") = oFile.Length
oRs.Fields("ContentType") = oFile.ContentType
oRs.Fields("BinaryData").AppendChunk = oFile.BinaryData & ChrB(0)
oRs.Update
oRs.Close
sSQL = "SELECT Top 1 FileID, FileName From Files Order By FileID Desc"
oRs.Open sSQL, oConn
If Not oRs.EOF Then
%>
File has been saved in database. View this file:
<%=oRs(1)%>
<%
End If
Set oRs = Nothing
Set oConn = Nothing
Set oFile = Nothing
Set oUpload = Nothing
%>
tofilesystem
<%
Dim oUpload
Dim oFile
Dim sFileName
Dim oFSO
Dim sPath
Dim sNewData
Dim nLength
Dim bytBinaryData
Dim sPath
Const nForReading = 1
Const nForWriting = 2
Const nForAppending = 8
' grab the uploaded file data
Set oUpload = New clsUpload
Set oFile = oUpload("File1")
' parse the file name
sFileName = oFile.FileName
If Not InStr(sFileName, "\") = 0 Then
sFileName = Mid(sFileName, InStrRev(sFileName, "\") + 1)
End If
' Convert the binary data to Ascii
bytBinaryData = oFile.BinaryData
nLength = LenB(bytBinaryData)
For nIndex = 1 To nLength
sNewData = sNewData & Chr(AscB(MidB(bytBinaryData, nIndex, 1)))
Next
' Save the file to the file system
sPath = Server.MapPath(".\Uploads") & "\"
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
oFSO.OpenTextFile(sPath & sFileName, nForWriting, True).Write sNewData
Set oFSO = Nothing
Set oFile = Nothing
Set oUpload = Nothing
%>
File has been saved in file system. View this file:
Uploads\<%=sFileName%>
Secondo il mio modesto parere c'è qualcosa di inesatto.....o da cambiare...
Grazie a tutti anticipatamente

Rispondi quotando

