Faço individualmente upload para uma galeria usando access, na minha tabela, possuo os campos: PIC_NAME, PIC_TYPE, PIC_DATED, PIC_IMAGE e assim por diante.
bem, minha dúvida é a seguinte, no campo PIC_IMAGE incluo o nome do arquivo da foto que depois chamarei no HTML, até ai tudo funcionando muito bem. Mas imagine se eu tiver 100 imagens, vou precisar incluir uma a uma.
Existe alguma forma de incluir todos os nomes de arquivos separados por "virgula" nesta coluna chamada "PIC_IMAGE" para depois chamar a galeria no HTML?
Ja vi alguns sistemas de multiplos arquivos, mas vou precisar mexer em toda estrutura, consigo adaptar o meu código nesta mudança?
enviarimagem.asp
<!--#include file="ScriptLibrary/incResizeAddOn.asp" --> <!--#include file="ScriptLibrary/incPureUpload.asp" --> <% '*** Pure ASP File Upload 2.1.7 Dim GP_uploadAction,UploadQueryString PureUploadSetup If (CStr(Request.QueryString("GP_upload")) <> "") Then Dim pau_thePath,pau_Extensions,pau_Form,pau_Redirect,pau_storeType,pau_sizeLimit,pau_nameConflict,pau_requireUpload,pau_minWidth,pau_minHeight,pau_maxWidth,pau_maxHeight,pau_saveWidth,pau_saveHeight,pau_timeout,pau_progressBar,pau_progressWidth,pau_progressHeight pau_thePath = """../images""" pau_Extensions = "GIF,JPG,JPEG,BMP,PNG" pau_Form = "form1" pau_Redirect = "" pau_storeType = "file" pau_sizeLimit = "" pau_nameConflict = "uniq" pau_requireUpload = "false" pau_minWidth = "" pau_minHeight = "" pau_maxWidth = "" pau_maxHeight = "" pau_saveWidth = "" pau_saveHeight = "" pau_timeout = "600" pau_progressBar = "" pau_progressWidth = "800" pau_progressHeight = "596" Dim RequestBin, UploadRequest CheckPureUploadVersion 2.17 ProcessUpload pau_thePath,pau_Extensions,pau_Redirect,pau_storeType,pau_sizeLimit,pau_nameConflict,pau_requireUpload,pau_minWidth,pau_minHeight,pau_maxWidth,pau_maxHeight,pau_saveWidth,pau_saveHeight,pau_timeout end if %> <% ' *** Smart Image Processor 1.1.2 If (CStr(Request.QueryString("GP_upload")) <> "") Then Dim RUF_Component, RUF_DotNetResize, RUF_ResizeImages, RUF_AspectImages, RUF_maxWidth, RUF_maxHeight, RUF_Quality, RUF_MakeThumb, RUF_AspectThumb, RUF_Suffix, RUF_maxWidthThumb, RUF_maxHeightThumb, RUF_QualityThumb, RUF_RedirectURL RUF_Component = "AUTO" RUF_DotNetResize = "../ScriptLibrary/ResizeImage.aspx" RUF_ResizeImages = true RUF_AspectImages = true RUF_maxWidth = "800" RUF_maxHeight = "596" RUF_Quality = "80" RUF_MakeThumb = true RUF_AspectThumb = true RUF_Suffix = "_small" RUF_maxWidthThumb = "130" RUF_maxHeightThumb = "130" RUF_QualityThumb = "70" RUF_RedirectURL = "" if RUF_ResizeImages then ResizeUploadedFiles RUF_Component, RUF_DotNetResize, pau_thePath, "", RUF_maxWidth, RUF_maxHeight, RUF_Quality, true, pau_saveWidth, pau_saveHeight, RUF_AspectImages, pau_nameConflict, "" end if if RUF_MakeThumb then ResizeUploadedFiles RUF_Component, RUF_DotNetResize, pau_thePath, RUF_Suffix, RUF_maxWidthThumb, RUF_maxHeightThumb, RUF_QualityThumb, false, pau_saveWidth, pau_saveHeight, RUF_AspectThumb, pau_nameConflict, "" end if if RUF_RedirectURL <> "" then Response.Redirect RUF_RedirectURL end if end if %> <% ' *** Edit Operations: (Modified for File Upload) declare variables Dim MM_editAction Dim MM_abortEdit Dim MM_editQuery Dim MM_editCmd Dim MM_editConnection Dim MM_editTable Dim MM_editRedirectUrl Dim MM_editColumn Dim MM_recordId Dim MM_fieldsStr Dim MM_columnsStr Dim MM_fields Dim MM_columns Dim MM_typeArray Dim MM_formVal Dim MM_delim Dim MM_altVal Dim MM_emptyVal Dim MM_i MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")) If (UploadQueryString <> "") Then MM_editAction = MM_editAction & "?" & UploadQueryString End If ' boolean to abort record edit MM_abortEdit = false ' query string to execute MM_editQuery = "" %> <% ' *** Insert Record: (Modified for File Upload) set variables If (CStr(UploadFormRequest("MM_insert")) = "form1") Then MM_editConnection = MM_connDUportal_STRING MM_editTable = "PICTURES" MM_editRedirectUrl = "submitimage.asp" MM_fieldsStr = "PIC_TYPE|value|PIC_NAME|value|PIC_PICTURE|value|PIC_DATED|value|PIC_DESCRIPTION|value|PIC_HEIGHT|value|PIC_WIDTH|value|PIC_APPROVED|value" MM_columnsStr = "PIC_TYPE|none,none,NULL|PIC_NAME|',none,''|PIC_IMAGE|',none,''|PIC_DATED|',none,NULL|PIC_DESCRIPTION|',none,''|PIC_HEIGHT|',none,''|PIC_WIDTH|',none,''|PIC_APPROVED|none,none,NULL" ' create the MM_fields and MM_columns arrays MM_fields = Split(MM_fieldsStr, "|") MM_columns = Split(MM_columnsStr, "|") ' set the form values For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_fields(MM_i+1) = CStr(UploadFormRequest(MM_fields(MM_i))) Next ' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And UploadQueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And UploadQueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & UploadQueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & UploadQueryString End If End If End If %> <% ' *** Insert Record: (Modified for File Upload) construct a sql insert statement and execute it Dim MM_tableValues Dim MM_dbValues If (CStr(UploadFormRequest("MM_insert")) <> "") Then ' create the sql insert statement MM_tableValues = "" MM_dbValues = "" For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_formVal = MM_fields(MM_i+1) MM_typeArray = Split(MM_columns(MM_i+1),",") MM_delim = MM_typeArray(0) If (MM_delim = "none") Then MM_delim = "" MM_altVal = MM_typeArray(1) If (MM_altVal = "none") Then MM_altVal = "" MM_emptyVal = MM_typeArray(2) If (MM_emptyVal = "none") Then MM_emptyVal = "" If (MM_formVal = "") Then MM_formVal = MM_emptyVal Else If (MM_altVal <> "") Then MM_formVal = MM_altVal ElseIf (MM_delim = "'") Then ' escape quotes MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'" Else MM_formVal = MM_delim + MM_formVal + MM_delim End If End If If (MM_i <> LBound(MM_fields)) Then MM_tableValues = MM_tableValues & "," MM_dbValues = MM_dbValues & "," End If MM_tableValues = MM_tableValues & MM_columns(MM_i) MM_dbValues = MM_dbValues & MM_formVal Next MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")" If (Not MM_abortEdit) Then ' execute the insert Set MM_editCmd = Server.CreateObject("ADODB.Command") MM_editCmd.ActiveConnection = MM_editConnection MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close If (MM_editRedirectUrl <> "") Then Response.Redirect(MM_editRedirectUrl) End If End If End If %> <% Dim rsType Dim rsType_numRows Set rsType = Server.CreateObject("ADODB.Recordset") rsType.ActiveConnection = MM_connDUportal_STRING rsType.Source = "SELECT * FROM TYPES ORDER BY TYPE_NAME ASC" rsType.CursorType = 0 rsType.CursorLocation = 2 rsType.LockType = 1 rsType.Open() rsType_numRows = 0 %> <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);} } //--> </script> <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);} } //--> </script> <script language="javascript" src="../ScriptLibrary/incPureUpload.js"></script> <div class="row"> <div class="col-md-12"> <article class="widget"> <header class="widget__header"> <h3 class="widget__title"><a href="#" onclick="return false;" class="btn btn-red"><i class="pe-7f-video"></i></a>Enviar nova imagem</h3> <div class="widget__config"> </div> </header> <div class="widget__content"> <table class="table"> <form action="<%=MM_editAction%>" method="post" enctype="multipart/form-data" name="form1" onSubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','PIC_WIDTH','PIC_HEIGHT');return document.MM_returnValue"> <tbody> <tr> <td>CATEGORIA:</td> <td><select name="PIC_TYPE" class="input-text" id="PIC_TYPE"> <% While (NOT rsType.EOF) %> <option value="<%=(rsType.Fields.Item("TYPE_ID").Value)%>"><%=(rsType.Fields.Item("TYPE_NAME").Value)%></option> <% rsType.MoveNext() Wend If (rsType.CursorType > 0) Then rsType.MoveFirst Else rsType.Requery End If %> </select> </td> </tr> <tr> <td>NOME:</td> <td> <input name="PIC_NAME" type="text" class="input-text" value="" size="32" maxlength="100"> </td> </tr> <tr> <td>IMAGEM:</td> <td> <input name="PIC_PICTURE" type="file" class="input-text" id="PIC_PICTURE" onChange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','PIC_WIDTH','PIC_HEIGHT')" size="35"></td> </tr> <tr> <td>DATA:</td> <td> <input name="PIC_DATED" type="text" class="input-text" value="<%= date() %>" size="20"> </td> </tr> <tr> <td nowrap align="right" valign="top">DESCRIÇÃO:</td> <td valign="baseline"> <textarea name="PIC_DESCRIPTION" cols="50" rows="5" class="textarea"></textarea> </td> </tr> <tr> <td> <input type="hidden" name="PIC_HEIGHT" value="" size="32"> <input type="hidden" name="PIC_WIDTH" value="" size="32"> <input type="hidden" name="PIC_APPROVED" value="1" size="32"> <input type="hidden" name="MM_insert" value="form1"> </td> <td> <input name="submit" type="submit" class="btn btn-red pull-right" id="submit" value="Enviar"> </td> </tr> </tbody> </form> </table> </article><!-- /widget --> </div> </div> <!-- /row --> <% rsType.Close() Set rsType = Nothing %>