.dsy:it.
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)


Posted by dan on 29-01-2004 16:06:

Exclamation 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.


Posted by [D]ani[J] on 29-01-2004 17:49:

prova a buttare un'occhio QUA

__________________
Dani
e-mail: DaniJ@dsy.it
...ahhh ste donne! :D
Buoniiiiiisssimaaaa!


Posted by ripe on 29-01-2004 18:31:

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!»


Posted by GaL3n on 30-01-2004 13:25:

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"

%>


Posted by fabpicca on 30-01-2004 13:37:

...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)


Posted by dan on 30-01-2004 14:55:

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!


Posted by ripe on 30-01-2004 16:00:

Originally posted by fabpicca
...giusto per rimanere in tema...


PHP RULEZ


Uhm... e su quali basi lo dici?? Secondo me non hai mai scritto una sola riga di ASP... :asd:

:roll:

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


Posted by fabpicca on 30-01-2004 17:49:

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)


Posted by korn on 30-01-2004 18:55:

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.


Posted by Rocco.Li on 30-01-2004 21:41:

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


Posted by dan on 01-02-2004 13:24:

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"

%>


E come faccio a dirgli in che directory mettere il file?
Per i permessi come funziona?

Grazie, D.


Posted by ripe on 01-02-2004 19:49:

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...


Terrificante. Sono dei punti talmente critici da rendere SCHIACCIANTE la superiorità di php rispetto ad asp. Avevi ragione.
































:rotfl:

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


Posted by Rocco.Li on 02-02-2004 15:25:

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


Posted by dan on 16-02-2004 08:32:

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)...


:cannabis: ?


Posted by Rocco.Li on 16-02-2004 11:08:

Originally posted by dan
:cannabis: ?


:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr::prr::prr::prr::prr::prr:
:prr::prr::prr::prr::prr:

__________________
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


Posted by dan on 16-02-2004 11:40:

Originally posted by Rocco.Li
:prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr::prr::prr::prr::prr::p
rr::prr::prr::prr::prr::prr:


:lol:


All times are GMT. The time now is 11:11.
Show all 16 posts from this thread on one page

Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.