By 14 Dicembre 2010 0 Comments

AspSmartUpload – Esempio 2: con i «file» di raccolta

Carica uno o più file sul server, recupera e visualizza i dettagli dei file inviati.
Il modulo HTML permette all’utente di selezionare il file(s). Il file ASP utilizza aspSmartUpload per salvare i file sul disco del server e per visualizzare i dettagli di ogni file (nome, estensione, dimensione, tipo, ecc.)
In questo esempio, prendiamo in esame il «Files» di raccolta. Per ogni file del modulo che viene effettivamente inviato, le proprietà corrispondenti sono visualizzati e il file viene salvato in una directory virtuale sul server web.

Esempio di pagina HTML che esegue il POST :
<HTML>
<BODY BGCOLOR="white">
<H1>aspSmartUpload : Sample 1</H1><HR>
<FORM METHOD="POST" ACTION="Sample1.asp" ...
...ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="FILE1" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE2" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE3" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE4" SIZE="50"><BR>
<INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM>
</BODY>
</HTML>

Esempio di pagina ASP che riceve il POST :


<HTML>
<BODY BGCOLOR="white">
<H1>aspSmartUpload : Sample 2</H1>
<HR>
<%
' Variables
' *********
Dim mySmartUpload
Dim file
Dim intCount
intCount=0
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Upload
' ******
mySmartUpload.Upload
' Select each file
' ****************
For each file In mySmartUpload.Files
' Only if the file exist
' **********************
If not file.IsMissing Then
' Save the files with his original names in a
'virtual path of the web server
' *******************************
file.SaveAs("/aspSmartUpload/Upload/" & file.FileName)
' sample with a physical path
' file.SaveAs("c:temp" & file.FileName)
' Display the properties of the current file
' ******************************************
Response.Write("Name = " & file.Name & "<BR>")
Response.Write("Size = " & file.Size & "<BR>")
Response.Write("FileName = " & file.FileName & "<BR>")
Response.Write("FileExt = " & file.FileExt & "<BR>")
Response.Write("FilePathName = " & file.FilePathName & "<BR>")
Response.Write("ContentType = " & file.ContentType & "<BR>")
Response.Write("ContentDisp = " & file.ContentDisp & "<BR>")
Response.Write("TypeMIME = " & file.TypeMIME & "<BR>")
Response.Write("SubTypeMIME = " & file.SubTypeMIME & "<BR>")
intCount = intCount + 1
End If
Next
' Display the number of files which could be uploaded
' ***************************************************
Response.Write("<BR>" & mySmartUpload.Files.Count & " files could be uploaded.<BR>")
' Display the number of files uploaded
' ************************************
Response.Write(intCount & " file(s) uploaded.<BR>")
%>
</BODY>
</HTML>


Posted in: AspSmartUpload

About the Author:

shared on wplocker.com