Ir para conteúdo

POWERED BY:

Arquivado

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

Yuki-kun

Upload

Recommended Posts

Estou a 2 meses tentando fazer um script de upload

que permita que o usuário pelo formulario que seleciona o

arquivo, escolher a partir de um ComboBox, o destino do próprio.

 

 

Mas, o asp não permite usar Querystring ou form. Já tentei de várias

formas, a que chegou proximo, apareceu o conteudo dos itens do form

em branco. Amanha vou postar meu código aqui.

 

Por favor, alguem me explique como fazer isso!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Qual componente de upload você usa? O padrão normal é resgatar os dados que não são o arquivo da seguinte forma:

ObjetoDeUpload.FORM("NomedoCampo")
'OU
ObjetoDeUpload("NomedoCampo")

Compartilhar este post


Link para o post
Compartilhar em outros sites

Estou usando o FreeASPUpload

 

http://www.freeaspupload.net/

 

<%@ Language=VBScript %>
<% 
option explicit 
Response.Expires = -1
Server.ScriptTimeout = 600
%>
<!--#include virtual="/includes/freeaspupload.asp" -->
<%
' ****************************************************
' Change the value of the variable below to the pathname
' of a directory with write permissions, for example "C:\Inetpub\wwwroot"
' ****************************************************

' Note: this file uploadTester.asp is just an example to demonstrate
' the capabilities of the freeASPUpload.asp class. There are no plans
' to add any new features to uploadTester.asp itself. Feel free to add
' your own code. If you are building a content management system, you
' may also want to consider this script: http://www.webfilebrowser.com/

Dim Upload, uploadsDirVar
Set Upload = New FreeASPUpload
uploadsDirVar = Request.ServerVariables("APPL_PHYSICAL_PATH") & "registro\"

if Upload.Form("usuario") <> "" then
	uploadsDirVar = uploadsDirVar & Upload.Form("usuario") & "\" & Upload.Form("tipo") & "\"
end if

function OutputForm()
%>
	<form name="frmSend" method="POST" enctype="multipart/form-data" action="registro.asp" onSubmit="return onSubmitForm();">
	<B>Arquivos:</B><br>
	Arquivo 1: <input name="attach1" type="file" size=35><br>
	Arquivo 2: <input name="attach2" type="file" size=35><br>
	Arquivo 3: <input name="attach3" type="file" size=35><br>
	Arquivo 4: <input name="attach4" type="file" size=35><br>
	<br>
	usuarios:<br>
	<select name="usuario">
		<option value="Administrador">Administrador</option>
		<option value="Editor">Editor</option>
		<option value="Revisor">Revisor</option>
	</select><br>
	Tipo de registro:<br>
	<select name="tipo">
		<option value="email">E-mail</option>
		<option value="word">Documento Word</option>
		<option value="excel">Excel</option>
		<option value="pdf">PDF</option>
		<option value="sgq">SGQ</option>
		<option value="outros">Outros</option>
	</select><br>
	<input style="margin-top:4" type=submit value="Enviar">
	</form>
<%
end function

function TestEnvironment()
	Dim fso, fileName, testFile, streamTest
	TestEnvironment = ""	
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	if not fso.FolderExists(uploadsDirVar) then
		TestEnvironment = "<B>Pasta " & uploadsDirVar & " Não existe.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
		exit function
	end if
	fileName = uploadsDirVar & "\test.txt"
	on error resume next
	Set testFile = fso.CreateTextFile(fileName, true)
	If Err.Number<>0 then
		TestEnvironment = "<B>A pasta " & uploadsDirVar & "não tem permissões de escrita.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
		exit function
	end if
	Err.Clear
	testFile.Close
	fso.DeleteFile(fileName)
	If Err.Number<>0 then
		TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have delete permissions</B>, although it does have write permissions.<br>Change the permissions for IUSR_<I>computername</I> on this folder."
		exit function
	end if
	Err.Clear
	Set streamTest = Server.CreateObject("ADODB.Stream")
	If Err.Number<>0 then
		TestEnvironment = "<B>The ADODB object <I>Stream</I> is not available in your server.</B><br>Check the Requirements page for information about upgrading your ADODB libraries."
		exit function
	end if
	Set streamTest = Nothing
end function

function SaveFiles
	Dim Upload, fileName, fileSize, ks, i, fileKey

	Set Upload = New FreeASPUpload
	
	response.Write(uploadsDirVar)
	Upload.Save(uploadsDirVar)
	' If something fails inside the script, but the exception is handled
	If Err.Number<>0 then Exit function

	SaveFiles = ""
	ks = Upload.UploadedFiles.keys
	if (UBound(ks) <> -1) then
		SaveFiles = "<B>Arquivos enviados:</B> "
		for each fileKey in Upload.UploadedFiles.keys
			SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) "
		next
	else
		SaveFiles = "O nome do arquivo especificado no formulário não corresponde ao arquivo do sistema."
	end if
	SaveFiles = SaveFiles & "<br>Quantidade = " & Upload.Form("usuario") & "<br>"
	SaveFiles = SaveFiles & "Tipo = " & Upload.Form("tipo") & "<br>"
end function
%>

<HTML>
<HEAD>
<TITLE>Envio de Registros</TITLE>
<style>
BODY {background-color: white;font-family:arial; font-size:12}
</style>
<script>
function onSubmitForm() {
	var formDOMObj = document.frmSend;
	if (formDOMObj.attach1.value == "" && formDOMObj.attach2.value == "" && formDOMObj.attach3.value == "" && formDOMObj.attach4.value == "" )
		alert("Clique em PESQUISAR para escolher um arquivo.")
	else
		return true;
	return false;
}
</script>

</HEAD>

<BODY>

<br><br>
<div style="border-bottom: #A91905 2px solid;font-size:16">Envie registros para o servidor</div>
<%
Dim diagnostics
if Request.ServerVariables("REQUEST_METHOD") <> "POST" then
	diagnostics = TestEnvironment()
	if diagnostics<>"" then
		response.write "<div style=""margin-left:20; margin-top:30; margin-right:30; margin-bottom:30;"">"
		response.write diagnostics
		response.write "<p>Depois que corrigir este problema, atualize esta página."
		response.write "</div>"
	else
		response.write "<div style=""margin-left:150"">"
		OutputForm()
		response.write "</div>"
	end if
else
	response.write "<div style=""margin-left:150"">"
	OutputForm()
	response.write SaveFiles()
	response.write "<br><br></div>"
end if

%>
</BODY>
</HTML>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Qual componente de upload você usa? O padrão normal é resgatar os dados que não são o arquivo da seguinte forma:

ObjetoDeUpload.FORM("NomedoCampo")
'OU
ObjetoDeUpload("NomedoCampo")

 

Nenhum dos dois funciona!

 

=(

Compartilhar este post


Link para o post
Compartilhar em outros sites

Na documentação do FreeAspUpload não tem essa informação?

 

Dê uma olhada também em nosso "Laboratório de Scripts" que temos um tópico sobre Upload sem componentes que tem, também, essa funcionalidade com formulários.

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.