![]() |
Pages (2): [1] 2 » Show 150 posts per page |
.dsy:it. (http://www.dsy.it/forum/)
- Forum De Bell Tolls (http://www.dsy.it/forum/forumdisplay.php?forumid=7)
-- [web] Upload ASP (http://www.dsy.it/forum/showthread.php?threadid=8426)
Upload ASP
Ciao a tutti, ho urgente bisogno di sapere come fare l'upload di un file con ASP!
Se qualcuno sa come posso fare ... me lo dica!!!
Grazie, D.
prova a buttare un'occhio QUA
__________________
Dani
Quello è ASP.NET... credo che lui avesse bisogno ASP.
Allora, qui sotto ti incollo una classe comodissima... come si usa dovrebbe esserti abbastanza chiaro! 
%
Class FileUpload
Public Files
Private mcolFormElem
Private Sub Class_Initialize()
Set Files = Server.CreateObject("Scripting.Dictionary")
Set mcolFormElem = Server.CreateObject("Scripting.Dictionary")
End Sub
Private Sub Class_Terminate()
If IsObject(Files) Then
Files.RemoveAll()
Set Files = Nothing
End If
If IsObject(mcolFormElem) Then
mcolFormElem.RemoveAll()
Set mcolFormElem = Nothing
End If
End Sub
Public Property Get Form(sIndex)
Form = ""
If mcolFormElem.Exists(LCase(sIndex)) Then Form = mcolFormElem.Item(LCase(sIndex))
End Property
Public Default Sub Upload()
Dim biData, sInputName
Dim nPosBegin, nPosEnd, nPos, vDataBounds, nDataBoundPos
Dim nPosFile, nPosBound
biData = Request.BinaryRead(Request.TotalBytes)
nPosBegin = 1
nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
If (nPosEnd-nPosBegin) <= 0 Then Exit Sub
vDataBounds = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
nDataBoundPos = InstrB(1, biData, vDataBounds)
Do Until nDataBoundPos = InstrB(biData, vDataBounds & CByteString("--"))
nPos = InstrB(nDataBoundPos, biData, CByteString("Content-Disposition"))
nPos = InstrB(nPos, biData, CByteString("name="))
nPosBegin = nPos + 6
nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))
sInputName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
nPosFile = InstrB(nDataBoundPos, biData, CByteString("filename="))
nPosBound = InstrB(nPosEnd, biData, vDataBounds)
If nPosFile <> 0 And nPosFile < nPosBound Then
Dim oUploadFile, sFileName
Set oUploadFile = New FileCaricato
nPosBegin = nPosFile + 10
nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))
sFileName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
oUploadFile.FileName = Right(sFileName, Len(sFileName)-InStrRev(sFileName, "\"))
nPos = InstrB(nPosEnd, biData, CByteString("Content-Type:"))
nPosBegin = nPos + 14
nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
oUploadFile.ContentType = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
nPosBegin = nPosEnd+4
nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
oUploadFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
If oUploadFile.FileSize > 0 Then Files.Add LCase(sInputName), oUploadFile
Else
nPos = InstrB(nPos, biData, CByteString(Chr(13)))
nPosBegin = nPos + 4
nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
If Not mcolFormElem.Exists(LCase(sInputName)) Then mcolFormElem.Add LCase(sInputName), CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
End If
nDataBoundPos = InstrB(nDataBoundPos + LenB(vDataBounds), biData, vDataBounds)
Loop
End Sub
Private Function CByteString(sString)
Dim nIndex
For nIndex = 1 to Len(sString)
CByteString = CByteString & ChrB(AscB(Mid(sString,nIndex,1)))
Next
End Function
Private Function CWideString(bsString)
Dim nIndex
CWideString =""
For nIndex = 1 to LenB(bsString)
CWideString = CWideString & Chr(AscB(MidB(bsString,nIndex,1)))
Next
End Function
End Class
Class FileCaricato
Public ContentType
Public FileName
Public FileData
Public Property Get FileSize()
FileSize = LenB(FileData)
End Property
Public Sub SalvaSuDisco(sPath)
Dim oFS, oFile
Dim nIndex
If sPath = "" Or FileName = "" Then Exit Sub
If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
If Not oFS.FolderExists(sPath) Then Exit Sub
Set oFile = oFS.CreateTextFile(sPath & FileName, True)
For nIndex = 1 to LenB(FileData)
oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
Next
oFile.Close
End Sub
End Class
%>
__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»
Sicuramente quella di RIPe funge senza problemi in ogni:
<%
Dim bytetotali
Dim binario
Dim I, S
bytetotali = request.totalbytes
if bytetotali < 1000000 then
binario = request.BinaryRead(request.TotalBytes)
For I = 1 To LenB(binario)
S = S & Chr(AscB(MidB(binario, I, 1)))
Next
SimpleBinaryToString = S
else
Dim cl1, cl2, cl3, pl1, pl2, pl3
Dim L
cl1 = 1
cl2 = 1
cl3 = 1
L = LenB(binario)
Do While cl1<=L
pl3 = pl3 & Chr(AscB(MidB(binario,cl1,1)))
cl1 = cl1 + 1
cl3 = cl3 + 1
If cl3>300 Then
pl2 = pl2 & pl3
pl3 = ""
cl3 = 1
cl2 = cl2 + 1
If cl2>200 Then
pl1 = pl1 & pl2
pl2 = ""
cl2 = 1
End If
End If
Loop
S = pl1 & pl2 & pl3
end if
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\temp\fileprova.txt", ForWriting, True)
f.Write S
f.close
response.write "Ho ricevuto : " & bytetotali & " byte"
%>
...giusto per rimanere in tema...
PHP RULEZ
__________________
my website?|ubuntu linux|get Firefox|grazie Polonia |bagdad sour
"Come va che non ha le corna e le zampe di Caprone?" gli opposi. "Oh, Giuvà", mi disse il prete "adesso non si usa più.Satana è furbo". (I.Silone, Fontamara)
"Al giorno d'oggi non bisogna essere intelligenti, perchè la gente si offende" (un ubriacone)
"close your eyes / pay the price / for your paradise" (DM) "whatever you want to change/you'd better start changing it in your mind" (Transatlantic)
Sono d'accordo con te ma se su un server mi trovo Access e ASP non posso che utilizzare quelli !
Anche se , appena posso, uso PHP!
Originally posted by fabpicca
...giusto per rimanere in tema...
PHP RULEZ

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»
su quali basi lo dico?
test di performance ne trovi ovunque.
comunque...
potrebbe bastare se ti dicessi ad esempio che le variabili GET e POST sono passate come variabili globali e non necessitano di essere estratte da oggetti request?
o ad esempio che prima di attivare un server IIS ci penserei due volte visti gli enormi problemi di sicurezza, quando invece apache è il miglior webserver sistente per prestazioni e sicurezza?
o magari questa come la vedi?
PHP è gratuito.ASP si paga...a meno che non fai il furbo, certo...
__________________
my website?|ubuntu linux|get Firefox|grazie Polonia |bagdad sour
"Come va che non ha le corna e le zampe di Caprone?" gli opposi. "Oh, Giuvà", mi disse il prete "adesso non si usa più.Satana è furbo". (I.Silone, Fontamara)
"Al giorno d'oggi non bisogna essere intelligenti, perchè la gente si offende" (un ubriacone)
"close your eyes / pay the price / for your paradise" (DM) "whatever you want to change/you'd better start changing it in your mind" (Transatlantic)
Lavorando con entrambi penso di potermi permettere di dire che PHP è migliore, tuttavia in Italia c'è ancora troppa chiusura mentale verso linux, opensource & soci.
Quando sono io a dover scegliere o proporre punto su PHP, ma se i clienti insistono per avere il sito in ASP sinceramente non oppongo granché di resistenza.
__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.
Un'altra guerra di religione ? o l'ennesima crociata per tutto cio che e' targato microsoft ?
Un bel CHISSENEFREGA su cosa e' meglio ?
e come discutere se e piu' buono il gelato alla fragola o quello ai frutti di bosco...
__________________
Alcuni uomini vedono le cose come sono e dicono: << Perche' ? >>
Io sogno le cose come non sono mai state e dico: << Perche' No ? >>
George Barnard Shaw, Commediografo.
"non preoccuparti troppo, comunque vada la vita, non ne uscirai vivo !" - anonimo
Originally posted by GaL3n
Sicuramente quella di RIPe funge senza problemi in ogni:
<%
Dim bytetotali
Dim binario
Dim I, S
bytetotali = request.totalbytes
if bytetotali < 1000000 then
binario = request.BinaryRead(request.TotalBytes)
For I = 1 To LenB(binario)
S = S & Chr(AscB(MidB(binario, I, 1)))
Next
SimpleBinaryToString = S
else
Dim cl1, cl2, cl3, pl1, pl2, pl3
Dim L
cl1 = 1
cl2 = 1
cl3 = 1
L = LenB(binario)
Do While cl1<=L
pl3 = pl3 & Chr(AscB(MidB(binario,cl1,1)))
cl1 = cl1 + 1
cl3 = cl3 + 1
If cl3>300 Then
pl2 = pl2 & pl3
pl3 = ""
cl3 = 1
cl2 = cl2 + 1
If cl2>200 Then
pl1 = pl1 & pl2
pl2 = ""
cl2 = 1
End If
End If
Loop
S = pl1 & pl2 & pl3
end if
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\temp\fileprova.txt", ForWriting, True)
f.Write S
f.close
response.write "Ho ricevuto : " & bytetotali & " byte"
%>
Originally posted by fabpicca
su quali basi lo dico?
test di performance ne trovi ovunque.
comunque...
potrebbe bastare se ti dicessi ad esempio che le variabili GET e POST sono passate come variabili globali e non necessitano di essere estratte da oggetti request?
o ad esempio che prima di attivare un server IIS ci penserei due volte visti gli enormi problemi di sicurezza, quando invece apache è il miglior webserver sistente per prestazioni e sicurezza?
o magari questa come la vedi?
PHP è gratuito.ASP si paga...a meno che non fai il furbo, certo...

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»
Terrificante davvero.
Il gelato alla fragola devi pagarlo...
...quello ai frutti di bosco ha i lamponi globali sopra !!!
ah, devi essere anche aperto mentalmente per mangiarlo...
Wow quasi quasi da oggi mangio solo il gelato al gianduja (JSP)...
__________________
Alcuni uomini vedono le cose come sono e dicono: << Perche' ? >>
Io sogno le cose come non sono mai state e dico: << Perche' No ? >>
George Barnard Shaw, Commediografo.
"non preoccuparti troppo, comunque vada la vita, non ne uscirai vivo !" - anonimo
Originally posted by Rocco.Li
Terrificante davvero.
Il gelato alla fragola devi pagarlo...
...quello ai frutti di bosco ha i lamponi globali sopra !!!
ah, devi essere anche aperto mentalmente per mangiarlo...
Wow quasi quasi da oggi mangio solo il gelato al gianduja (JSP)...
?
Originally posted by dan
?







































































































































__________________
Alcuni uomini vedono le cose come sono e dicono: << Perche' ? >>
Io sogno le cose come non sono mai state e dico: << Perche' No ? >>
George Barnard Shaw, Commediografo.
"non preoccuparti troppo, comunque vada la vita, non ne uscirai vivo !" - anonimo
| All times are GMT. The time now is 22:25. | Pages (2): [1] 2 » Show all 16 posts from this thread on one page |
Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.