Ir para conteúdo

POWERED BY:

Arquivado

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

leozeferino

Pure ASP Upload 2.0

Recommended Posts

Olá.

 

 

Li o Artigo do Pure Upload 2.0 no Imaster e a materia caiu como uma luva.

 

Fiz o download do componente, instalei e configurei.

 

Fiz um formulário com um campo de arquivo e mais alguns campos de nome, email.

 

O que eu gostaria de fazer é: ao usuário enviar o formulário, o código enviaria o arquivo (se a pessoa escolher um arquivo para ser enviado) para o servidor e depois disso inserisse o nome do arquivo e os outros campos num banco de dados.

 

Enviar o arquivo, eu consegui, o problema é que eu não sei como e aonde inserir o código para enviar os campos e o nome do arquivo para o banco de dados.

 

Vou postar o código da página e se alguém souber como posso fazer isso, me ajude.

 

<!--#include file="../ScriptLibrary/incPureUpload.asp" --><%'*** Pure ASP File Upload -----------------------------------------------------' Copyright (c) 2001-2002 George Petrov, www.UDzone.com' Process the upload' Version: 2.0.9'------------------------------------------------------------------------------'*** File Upload to: """../arquivos""", Extensions: "GIF,JPG,JPEG,BMP,PNG,CDR,PSD", Form: form1, Redirect: "../index.asp", "file", "5000", "over", "true", "", "" , "", "", "", "", "600", "fileCopyProgress.htm", "300", "100"Dim GP_redirectPage, RequestBin, UploadQueryString, GP_uploadAction, UploadRequestPureUploadSetupIf (CStr(Request.QueryString("GP_upload")) <> "") Then  on error resume next  Dim reqPureUploadVersion, foundPureUploadVersion  reqPureUploadVersion = 2.09  foundPureUploadVersion = getPureUploadVersion()  if err or reqPureUploadVersion > foundPureUploadVersion then	Response.Write "<b>You don't have latest version of ScriptLibrary/incPureUpload.asp uploaded on the server.</b><br>"	Response.Write "This library is required for the current page. It is fully backwards compatible so old pages will work as well.<br>"	Response.End	  end if  on error goto 0  GP_redirectPage = "index1.asp"    Server.ScriptTimeout = 600    RequestBin = Request.BinaryRead(Request.TotalBytes)  Set UploadRequest = CreateObject("Scripting.Dictionary")    BuildUploadRequest RequestBin, """../arquivos""", "file", "5000", "over"    If (GP_redirectPage <> "" and not (CStr(UploadFormRequest("MM_insert")) <> "" or CStr(UploadFormRequest("MM_update")) <> "")) Then	If (InStr(1, GP_redirectPage, "?", vbTextCompare) = 0 And UploadQueryString <> "") Then	  GP_redirectPage = GP_redirectPage & "?" & UploadQueryString	End If	Response.Redirect(GP_redirectPage)    end if  else  if UploadQueryString <> "" then	UploadQueryString = UploadQueryString & "&GP_upload=true"  else  	UploadQueryString = "GP_upload=true"  end if  end if' End Pure Upload'------------------------------------------------------------------------------%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><script language="JavaScript"><!--function checkFileUpload(form,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight) { //v2.09  document.MM_returnValue = true;  for (var i = 0; i<form.elements.length; i++) {	field = form.elements[i];	if (field.type.toUpperCase() != 'FILE') continue;	checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);} }function checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight) { //v2.09  document.MM_returnValue = true;  if (extensions != '') var re = new RegExp("\.(" + extensions.replace(/,/gi,"|").replace(/\s/gi,"") + ")$","i");	if (field.value == '') {	  if (requireUpload) {alert('File is required!');document.MM_returnValue = false;field.focus();return;}	} else {	  if(extensions != '' && !re.test(field.value)) {		alert('This file type is not allowed for uploading.\nOnly the following file extensions are allowed: ' + extensions + '.\nPlease select another file and try again.');		document.MM_returnValue = false;field.focus();return;	  }	document.PU_uploadForm = field.form;	re = new RegExp(".(gif|jpg|png|bmp|jpeg)$","i");	if(re.test(field.value) && (sizeLimit != '' || minWidth != '' || minHeight != '' || maxWidth != '' || maxHeight != '' || saveWidth != '' || saveHeight != '')) {	  checkImageDimensions(field,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);	} }}function showImageDimensions(fieldImg) { //v2.09  var isNS6 = (!document.all && document.getElementById ? true : false);  var img = (fieldImg && !isNS6 ? fieldImg : this);  if (img.width > 0 && img.height > 0) {  if ((img.minWidth != '' && img.minWidth > img.width) || (img.minHeight != '' && img.minHeight > img.height)) {	alert('Uploaded Image is too small!\nShould be at least ' + img.minWidth + ' x ' + img.minHeight); return;}  if ((img.maxWidth != '' && img.width > img.maxWidth) || (img.maxHeight != '' && img.height > img.maxHeight)) {	alert('Uploaded Image is too big!\nShould be max ' + img.maxWidth + ' x ' + img.maxHeight); return;}  if (img.sizeLimit != '' && img.fileSize > img.sizeLimit) {	alert('Uploaded Image File Size is too big!\nShould be max ' + (img.sizeLimit/1024) + ' KBytes'); return;}  if (img.saveWidth != '') document.PU_uploadForm[img.saveWidth].value = img.width;  if (img.saveHeight != '') document.PU_uploadForm[img.saveHeight].value = img.height;  document.MM_returnValue = true;} }function checkImageDimensions(field,sizeL,minW,minH,maxW,maxH,saveW,saveH) { //v2.09  if (!document.layers) {	var isNS6 = (!document.all && document.getElementById ? true : false);	document.MM_returnValue = false; var imgURL = 'file:///' + field.value.replace(/\\/gi,'/').replace(/:/gi,'|').replace(/"/gi,'').replace(/^\//,'');	if (!field.gp_img || (field.gp_img && field.gp_img.src != imgURL) || isNS6) {field.gp_img = new Image();		   with (field) {gp_img.sizeLimit = sizeL*1024; gp_img.minWidth = minW; gp_img.minHeight = minH; gp_img.maxWidth = maxW; gp_img.maxHeight = maxH;		 gp_img.saveWidth = saveW; gp_img.saveHeight = saveH; gp_img.onload = showImageDimensions; gp_img.src = imgURL; }	 } else showImageDimensions(field.gp_img);}}function showProgressWindow(progressFile,popWidth,popHeight) { //v2.09  var showProgress = false, form, field;  for (var f = 0; f<document.forms.length; f++) {	form = document.forms[f];	for (var i = 0; i<form.elements.length; i++) {	  field = form.elements[i];	  if (field.type.toUpperCase() != 'FILE') continue;	  if (field.value != '') {showProgress = true;break;}  } }  if (showProgress && document.MM_returnValue) {	var w = 480, h = 340;	if (document.all || document.layers || document.getElementById) {	  w = screen.availWidth; h = screen.availHeight;}	var leftPos = (w-popWidth)/2, topPos = (h-popHeight)/2;	document.progressWindow = window.open(progressFile,'ProgressWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + popWidth + ',height='+popHeight);	document.progressWindow.moveTo(leftPos, topPos);document.progressWindow.focus();		window.onunload = function () {document.progressWindow.close();};} }//--></script><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><form action="<%=GP_uploadAction%>" method="post" enctype="multipart/form-data" name="form1" onSubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP,PNG,CDR,PSD',true,5000,'','','','','','');showProgressWindow('fileCopyProgress.htm',300,100);return document.MM_returnValue">  <input name="arquivo" type="file" id="arquivo" onChange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG,CDR,PSD',true,5000,'','','','','','')">   <br>  <br>  <input name="teste" type="text" id="teste">  <br>  <br>  <input type="submit" name="Submit" value="Submit"></form></body></html>

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.