Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Cesão

[Resolvido] Upload Múltiplo

Recommended Posts

Olá amigos,

 

uso o componente de upload SoftArtisans (SaFileUp).

Já entrei no site deles e NÃO consio achar de jeito nenhum como eu faço para fazer upload de varios arquivos de uma vez...

jah tentei simplesmente colocar dois campos no formulario, mas quando ele vai fazer o upload, ele faz apenas do primeiro campo e ignora o segundo...

 

Como faço para fazer dois uploads de uma vez, por exemplo?

 

Meu código está assim:

 

<!--#include file="conn/conexao.asp"--><!--#include file="espiao.asp"--><HTML><BODY>	<% Set upl = Server.CreateObject("SoftArtisans.FileUp") %>	<% upl.Path = "e:\home\exsa\web\novo\news" %><%pasta = ("news/")titulo = upl.form("titulo")data = upl.form("data")noticia = upl.form("noticia")thumb = upl.Form("thumb").ShortFileNamefoto = upl.Form("foto").ShortFileNameSQL="INSERT INTO tb_noticias (titulo, data, noticia, thumb, foto) VALUES('"&titulo&"','"&data&"','"&noticia&"','"&pasta&thumb&"','"&pasta&foto&"')"conexao.Execute(SQL)'Response.Write(SQL)%><% upl.Save %><% Set upl = Nothing %> </BODY></HTML><%conexao.CloseSet conexao = Nothing%><%Response.Redirect "admin_news.asp"%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

alguem pode me ajudar?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Provavelmente esses componentes free de upload sem componente não dão suporte a este tipo de sistema.

 

Eu te indico a tentar usar um for next ou seja ele repete o processo na quantidade de vezes que você mandar.

 

Ai fica facil se precisar de ajuda com for next é do dar um toque que eu te ajudo ok.

 

 

Falow

É cara... acho que vou precisar de ajuda com o for next sim. como ele funciona? tem algum tutorial dele bem simples na net?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Link para o arquivo de Documentação, nele tem esses exemplos:

form.asp

<%@ Language=VBScript %>
<% Option Explicit 
'-----------------------------------------------------------------------
'--- FileUp Multiple File Upload Sample
'--- 
'--- This sample demonstrates how to perform multiple file uploads
'--- with FileUp

'--- Copyright (c) 2003 SoftArtisans, Inc.
'--- Mail: info@softartisans.com   [url=http://www.softartisans.com]http://www.softartisans.com[/url]
'-----------------------------------------------------------------------
%>

<HTML>
<HEAD>
<TITLE>SoftArtisans FileUp Multiple File Upload Sample</TITLE>
</HEAD>

<BODY>
<p align=center>
<img src="/safileupsamples/fileupse.gif" alt="SoftArtisans FileUp">
</p>

<H3 ALIGN=center>FileUp Multiple File Upload Sample</H3>

<!--

Note: For any form uploading a file, the ENCTYPE="multipart/form-data" and 
METHOD="POST" attributes MUST be present

-->
<FORM ACTION="formresp.asp" ENCTYPE="MULTIPART/FORM-DATA" METHOD="POST">
<TABLE ALIGN=center border=0 width=600>
<TR>
<TD ALIGN="RIGHT" VALIGN="TOP">Select a file:</TD>

<!--
Note: Notice this form element is of TYPE="FILE"
-->	
<TD ALIGN="LEFT"><INPUT TYPE="FILE" NAME="myFile1">

</TD>
</TR>
<TR>
<TD ALIGN="RIGHT" VALIGN="TOP">Select a file:</TD>

<!--
Note: Notice this form element is of TYPE="FILE"
-->	
<TD ALIGN="LEFT"><INPUT TYPE="FILE" NAME="myFile2"><BR>
<I>Click "Browse" to select a file to upload</I>
</TD>
</TR>

<TR>
<TD ALIGN="RIGHT"> </TD>
<TD ALIGN="LEFT"><INPUT TYPE="SUBMIT" NAME="SUB1" VALUE="Upload Files"></TD>
</TR>
<tr>
<td colspan=2>
<hr noshade>
<b>Note:</b> This sample is much like the Simple upload sample except that it demonstrates how to handle multiple file upload fields.
</td>
</tr>
</TABLE>
</FORM>

</BODY>
</HTML>

formresp.asp

<%@ Language=VBScript %>
<% Option Explicit %>

<HTML>
<HEAD>
<TITLE>SoftArtisans FileUp Multiple File Upload Sample</TITLE>
</HEAD>
<BODY>
<p>
<img src="/safileupsamples/fileupse.gif" alt="SoftArtisans FileUp">
</p>

<%
'-----------------------------------------------------------------------
'--- FileUp Multiple File Upload Sample
'--- 
'--- This sample demonstrates how to perform a multiple file uploads
'--- with FileUp

'--- This is the ASP form-response script that uses FileUp to receive and
'--- process the upload submitted from form.asp

'--- Copyright (c) 2003 SoftArtisans, Inc.
'--- Mail: info@softartisans.com   http://www.softartisans.com
'-----------------------------------------------------------------------

'--- Declarations
Dim oFileUp

'--- Instantiate the FileUp object
Set oFileUp = Server.CreateObject("SoftArtisans.FileUp")

'--- Set the Path property to the location you wish to
'--- temporarily cache the incoming file before saving
'--- Note: This property must be set immediately after
'--- instantiating the FileUp object
oFileUp.Path = Server.MapPath(Application("vroot") & "/temp")

'--- Save the first file

'--- Check to be sure there was a file selected in the form
'--- If so, continue processing
If IsObject(oFileUp.Form("myFile1")) Then
	If Not oFileUp.Form("myFile1").IsEmpty Then

		'--- Save the file
		'--- Note: The Save() method saves the file
		'--- with its original name to the directory
		'--- you set as the Path property.
		'--- To save a file to a different location
		'--- or with a different name, use the SaveAs() method
		'--- instead of Save()
		On Error Resume Next
			oFileUp.Form("myFile1").Save
			If Err.Number <> 0 Then
				Response.Write "<B>An error occurred while saving the first file</B><BR>" & _
								Err.Description & " (" & Err.Source & ")"
				Response.End
			End If
		On Error Goto 0

		'--- The file is saved, display a confirmation message
		Response.Write "<B>First file saved successfully on the server as: </B>"

		'--- The ServerName() property is the full path of the file
		'--- where it was saved on the server
		Response.Write oFileUp.Form("myFile1").ServerName & "<BR>"

	Else
		Response.Write "Error: There was no file submitted for upload in the first field.<BR>"
	End If
Else
	Response.Write "The referenced field does not exist or is not of type=""file"""
End If

'--- Save the second file

'--- Check to be sure there was a file selected in the form
'--- If so, continue processing
If IsObject(oFileUp.Form("myFile2")) Then
	If Not oFileUp.Form("myFile2").IsEmpty Then

		'--- Save the file
		'--- Note: The Save() method saves the file
		'--- with its original name to the directory
		'--- you set as the Path property.
		'--- To save a file to a different location
		'--- or with a different name, use the SaveAs() method
		'--- instead of Save()
		On Error Resume Next
			oFileUp.Form("myFile2").Save
			If Err.Number <> 0 Then
				Response.Write "<B>An error occurred while saving the second file</B><BR>" & _
								Err.Description & " (" & Err.Source & ")"
				Response.End
			End If
		On Error Goto 0

		'--- The file is saved, display a confirmation message
		Response.Write "<B>Second file saved successfully on the server as:</B> "

		'--- The ServerName() property is the full path of the file
		'--- where it was saved on the server
		Response.Write oFileUp.Form("myFile2").ServerName

	Else
		Response.Write "Error: There was no file submitted for upload in the second field."
	End If
Else
	Response.Write "The referenced field does not exist or is not of type=""file"""
End If

'--- Destroy objects
Set oFileUp = Nothing
%>


</BODY>
</HTML>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Valeu salgado!! Eh isso mesmo!!

Soh precisei colocar um Save p cada um...

 

ao inves de colocar apenas upl.Save, coloquei:

 

upl.Form("foto").Save

upl.Form("thumb").Save

 

Dai salvou os dois!!

Valeu mesmo!!

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.