Suporte
 
Painel de Controle Insite
ASP

Upload de arquivos usando o componente Dundas Upload

1- Crie 2 (dois) arquivos: main.asp e process.asp;
2- Crie o diretório para onde serão enviados os arquivos. Ex.: Upload;

IMPORTANTE: Os arquivos e diretório devem estar no mesmo diretório e ter permissão de execução.

. main.asp
<%@ Language=VBScript %>
<% Response.Buffer = true
%>
<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</head>
<BODY color="black" bgcolor="white">
<P>
<BR>
<P>
<BR>
<font size="3"><div align="center">Exemplo de upload de 3 arquivos, cada
com no máximo 1 Mb utilizando Dundas Upload
</font></P></div>
<center>
<P>
<BR>
<form name="UploadForm" action="Process.asp"
enctype="multipart/form-data" method="post" style="BORDER-BOTTOM: thin;
BORDER-RIGHT-STYLE: none">
<%
'if an upload operation just occurred output success/failure message to
user
if Request.QueryString("Message") <> "" then
Response.Write "<font color=blue><b>" &
Request.QueryString("Message") & "</font></b><br><br>"
end if
%>
<p style="BACKGROUND-COLOR: #D4DBDE; BORDER-BOTTOM: thin solid;
BORDER-LEFT: thin solid; BORDER-RIGHT: thin solid; BORDER-TOP: thin
solid; WIDTH: 400px">
<font color="#000000"><B>  EXEMPLO DUNDAS UPLOAD -
INSITE</font></B>
<table width="400" border="0" cellPadding="3" cellSpacing="3"
style="BACKGROUND-COLOR: #CCCCCC" align="center">
<tr>
<td>Informe seu Nome: </td>
<td><input type="textbox" name="txtName"></td>
</tr>
<tr>
<td>Arquivo #1: </td>
<td><input NAME="File1" TYPE="file"></td></tr>
<TR>
<td>Arquivo #2: </td>
<td><input NAME="File2" TYPE="file"></td></TR>
<TR>
<td>Arquivo #3: </td>
<td><input NAME="File3" TYPE="file"></td></TR>
</table></p>
<p>
<input type="submit" value="Enviar" id="submit1" name="submit1">
<br></form></P></center>
</BODY>
</html>
. process.asp
<%@ Language=VBScript %>
<% Response.Buffer = true
on error resume next

dim objUpload 'instance of Uplaod control
dim strMessage 'stores success/failure message sent back to
main.asp

'create an instance of the Upload Control and trap for object creation
failure
set objUpload = server.CreateObject("Dundas.Upload.2")
if err.number <> 0 then
Response.Redirect "main.asp?Message=" & err.description
end if

'set maximum file size allowed to approx. 1 MBytes
objUpload.MaxFileSize = 2000000

'save all uploaded form data to memory. Note that this also populates
the Files and
' Form collections with ALL uploaded form data
'objUpload.Save "repository"
filePath= Server.MapPath("upload")
objUpload.Save filePath

'now trap for success/failure of operation, and also use the control's
Form collection
' to retrieve the name entered by the user so we can send his/her
name back to main.asp
dim temp
if IsEmpty(objUpload.Form("txtName")) = false then temp = " "
if err.number <> 0 then
strMessage = "Sorry " & objUpload.Form("txtName") & temp & "but
the following error occurred: " & err.description & filePath
else
strMessage = "The upload operation was successfully performed" &
temp & objUpload.Form("txtName") & "."
end if

'now use a response.redirect to get user back to main.asp
Response.Redirect "main.asp?Message=" & strMessage

'release resources
set objUpload = nothing
%>