non riesco a modificare questi file che ho scaricato in giro, servono ad eseguire l'upload di file immagine:
Ho due file: upload.asp e form.asp
codice: upload.asp
<%
'Questa variabile setta il percorso di dove effettuare l'upolad
'la cartella non puo non esistere lo script non la crea ! ! !
percorso = "/demo/rsta/public/motor_rally/"
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)
' Recupero i campi se sono compilati
if instr(Intestazione,"testo1") > 0 then
testo1 = ContenutoFile
end if
' Nel caso in cui fossero presenti piu campi basta duplicare
' la condizione cambiando unicamente il nome del campo
' es.
'if instr(Intestazione,"testo2") > 0 then
' testo2 = ContenutoFile
'end if
'if instr(Intestazione,"testo3") > 0 then
' testo3 = 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)
NomeFile1 = 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 condizioneo 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")
' Upload2 = True
' DimensioneFile2 = len(ContenutoFile)
' EstensioneFile2 = right(ContenutoFile,3)
' NomeFile2 = 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
'if instr(Intestazione,"file3") > 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")
' Upload3 = True
' DimensioneFile3 = len(ContenutoFile)
' EstensioneFile3 = right(ContenutoFile,3)
' NomeFile3 = NomeFile
' Set textStream = FSO.CreateTextFile(server.mappath(percorso & NomeFile3), True, False)
' textStream.Write ContenutoFile
' textStream.Close
' Set textStream = Nothing
' Set FSO = Nothing
' end if
'end if
next
' Da qui in poi è possibile fare esegiure allo script altre operazioni
' inserire qui gli script aggiuntivi che si vogliono eseguire dopo l'upload
' Per esempio visualizzare quello che è stato inserito all'interno del
' compo testo
Response.Write "Il valore immesso nella testo1 è " & testo1 & "
"
' Utilizzando il sistema descritto sopra è possibile visualizzare campi
' testo aggiuntivi presenti nel form
' Response.Write "Il valore immesso nella testo2 è " & testo2 & "
"
' Response.Write "Il valore immesso nella testo3 è " & testo3 & "
"
' E la stessa cosa per i campi dove è stato eseguito l'upload dei file
If Upload1 = true then
Response.Write "
La dimensione del file che hai uploadato è di " & DimensioneFile1*0.001 & "kb"
Response.Write "
Grazie di aver inviato il tuo file"
Response.Write "
NomeUpload: " & NomeUpload &"
"& "Intestazione: " & Intestazione&"
" & "NomeFile1: " & NomeFile1&"
"& "testo1: " & testo1&"
"& "NomeFile: " & NomeFile&"
" & "ContenutoFile: " & ContenutoFile&"
" & "Inizio: " & Inizio&"
" & "NomeFile: " & NomeFile&"
"
End If
'If Upload2 = true then
' Response.Write "
La dimensione del file che hai uploadato è di " & DimensioneFile2*0.001 & "kb"
' Response.Write "
Grazie di aver inviato il tuo file"
'End If
'If Upload3 = true then
' Response.Write "
La dimensione del file che hai uploadato è di " & DimensioneFile3*0.001 & "kb"
' Response.Write "
Grazie di aver inviato il tuo file"
'End If
End if
%>
codice: form.asp:
<form action="upload.asp" method="post" enctype="multipart/form-data">
<table width="300" border="0" cellspacing="2" cellpadding="0">
<tr>
<td class="backstagetesto">immagine da sostituire:</td>
<td><input name="testo1" type="text" class="backstagebottoni"></td>
</tr>
<tr>
<td class="backstagetesto">File:</td>
<td><input name="file1" type="file" class="backstagebottoni"></td>
</tr>
<tr>
<td></td>
<td><input name="submit" type="submit" class="bottoni" value="Upload"></td>
</tr>
</table>
</form>
non riesco a rinominare i file dei quali ottengo l'upload con il nome che inserisco nel campo input name="testo1"
VI RINGRAZIO ANDICIPATAMENTE, FORSE è UN MESSAGGIO UN PO' LUNGO, NON PARTECIPO SPESSO AI FORUM! MA è TUTTO IL POMERIGGIO CHE MI SCORNO CON QUESTA COSA! HELP!

Rispondi quotando
