codice:
<%
'Questa variabile setta il percorso di dove effettuare l'upolad
'la cartella non puo non esistere lo script non la crea ! ! !
percorso = "/public/foto/"
ByteRicevuti = Request.TotalBytes
if ByteRicevuti > 0 then
DatiRicevuti = Request.BinaryRead(ByteRicevuti)
For i = 1 To lenB(DatiRicevuti)
FileBinario = FileBinario & chr(ascB(midB(DatiRicevuti,i,1)))
Next
FirmaFile = left(FileBinario,instr(FileBinario,"" & vbCrLf)-1)
ArrPezzi = split(FileBinario,FirmaFile)
for item = 1 to ubound(ArrPezzi)-1
Inizio = instr(ArrPezzi(item),"" & vbCrLf & "" & vbCrLf)
Intestazione = left(ArrPezzi(item),Inizio-1)
Inizio = Inizio + len("" & vbCrLf) + len("" & vbCrLf)
ContenutoFile = mid(ArrPezzi(item),Inizio,len(ArrPezzi(item))-Inizio-1)
'if instr(Intestazione,"testo0") > 0 then
' testo0 = replace(trim((ContenutoFile)),"'","'")
'end if
' Recupero i campi se sono compilati
if instr(Intestazione,"testo1") > 0 then
testo1 = replace(trim((ContenutoFile)),"'","'")
end if
if instr(Intestazione,"testo2") > 0 then
testo2 = replace(trim((ContenutoFile)),"'","'")
end if
if instr(Intestazione,"testo3") > 0 then
testo3 = replace(trim((ContenutoFile)),"'","'")
end if
' Qui recupero il file da uploadare (se presente) e lo scrivo
' sul server
if instr(Intestazione,"file1") > 0 then
i = instr(Intestazione,"filename=")
j = instr(i + 10,Intestazione,chr(34))
NomeUpload = mid(Intestazione,i + 10,j-i-10)
i = instrRev(NomeUpload,"\")
if i<>0 then
NomeFile = mid(NomeUpload,i + 1)
else
NomeFile = NomeUpload
end if
if i<>0 then
Set FSO = CreateObject("Scripting.FileSystemObject")
Upload1 = True
DimensioneFile1 = len(ContenutoFile)
EstensioneFile1 = right(ContenutoFile,3)
Randomize( )
genero=Int(10000*Rnd( ))
NomeFile1 = genero&NomeFile
Set textStream = FSO.CreateTextFile(server.mappath(percorso & NomeFile1), True, False)
textStream.Write ContenutoFile
textStream.Close
Set textStream = Nothing
Set FSO = Nothing
end if
end if
' Lo stesso discorso vale anche per i campi dei file :
' Nel caso in cui fossero presenti piu file basta duplicare
' la condizione cambiando unicamente il nome del campo
' es.
if instr(Intestazione,"file2") > 0 then
i = instr(Intestazione,"filename=")
j = instr(i + 10,Intestazione,chr(34))
NomeUpload = mid(Intestazione,i + 10,j-i-10)
i = instrRev(NomeUpload,"\")
if i<>0 then
NomeFile = mid(NomeUpload,i + 1)
else
NomeFile = NomeUpload
end if
if i<>0 then
Set FSO = CreateObject("Scripting.FileSystemObject")
Upload1 = True
DimensioneFile2 = len(ContenutoFile)
EstensioneFile2 = right(ContenutoFile,3)
Randomize( )
genero=Int(10000*Rnd( ))
NomeFile2 = genero&NomeFile
Set textStream = FSO.CreateTextFile(server.mappath(percorso & NomeFile2), True, False)
textStream.Write ContenutoFile
textStream.Close
Set textStream = Nothing
Set FSO = Nothing
end if
end if
next
If Upload1 = true then
Response.Write "<center>
Caricamento riuscito! La dimensione della foto che hai uploadato è di " & DimensioneFile1*0.001 & "kb"
Response.Write "
Il titolo della foto "& testo1&" , il tuo file è stato registrato sul database il "&now()&"."
%>
<%
sql = "INSERT into riviste (copertina,pdf,anno,numero,del)"
sql = sql & " values('"&replace(nomeFile1," ", "%20")&"', '"&replace(nomeFile2," ", "%20")&"', '"&testo1&"', '"&testo2&"', '"&testo3&"')"
connession.Execute (sql)
set sql = nothing
%>
<html><center>
CARICAMENTO RIVISTA... Attendere prego</center><meta http-equiv="refresh" content="7;url=admin.asp?sezione=elencoriviste"></html>
<%
Else
Response.Write "<center>ERRORE, SI DEVONO SPECIFICARE TUTTI I DETTAGLI.</center>"
End If
End if
%>