Jump to content
Fórum Script Brasil
  • 0

Upload de imagem + descrição


Guilherme S

Question

Boa Noite pessoal,sou iniciante no forum , e no mundo ASP

minha duvida é a seguinte,tenho um sistema de upload de imagens

utilizando junto com uma BD em ACCESS, o que eu preciso é gravar junto a imagem uma descrição referente

a mesma que vai ser inserido em um Campo de texto na hora do upload,ESTOU MEIO perdido não sei como e por

onde começar essa adptação...

SEGUE o código com os forms que selecionam as imagem (lembrando que tera uma descriçao diferente para cada imagem

sendo assim um Campo de texto para cada imagem selecionada)

PÁGINA INSERIRFOTOS.ASP

<%
   if not session("status") = "ok" then
      response.redirect("login.asp?erro=negado")
   else
%>

<!--#include file="html.asp"-->
    <title><%=tituloSite%> - Fotos</title>
    
    <!--#include file="header.asp"-->
<!--#include file="htmlClose.asp"-->
<body class="bodySistema">
    <div id="tudo">
        <div id="conteudo">
            <div id="header">
            <%

            If session("paginaFotos") = "0" Then 
                  Response.redirect "index.asp"
                  Response.End
            End If
    
            %>
                <div id="logo">
                    <a href="index.asp"><img src="../imagens/logo.jpg" border="0" /></a>
                </div>
                <div id="menuSistema">
                    <!--#include file="controleSistema.asp"-->
                    <div id="tabsMenu">
                        <!--#include file="menu.asp"-->
                    </div>
                </div>
            </div>
            <div id="luzTopo">
                 
            </div>
            <div id="info">
                        
            function enviar(){
                d=document.upload
                d.submit();
                document.getElementById('cmdEnviar').style.display='none';
                document.getElementById('loading').style.display='inline';
                document.getElementById('myTable').style.display='none';            
            }
            </script>
                <div id="barraTituloSistema">
                    <div id="icone"><img src="../imagens/iconeFoto.png" border="0" /></div>
                <% 
                tituloAlbum = request.querystring("album")
                idAlbum = request.querystring("id")                
                %>
                    <div id="tituloSistema">
                        <a href="inserirFoto.asp?album=<%=tituloAlbum%>" title="Inserir"><img src="imagens/botaoInserir.png" border="0" alt="Inserir" align="absmiddle" /></a> fotos » <%=tituloAlbum%> » inserir foto
                    </div>
                </div>
                <a href="java script:self.history.go(-1)" class="voltar">« voltar</a>
                <br><br>
                <form action="upload.asp?id=<%=idAlbum%>&album=<%=tituloAlbum%>" method="post" enctype="multipart/form-data" name="upload" id="upload" onsubmit="return desabilitar_botao()">
                    <div id="conteudoEsquerda" style="width:100%;">
                        <table width="360" border="0" id="myTable">
                            <tr>
                              <td>
                                <input type="file" name="Arquivo1" size="50" />
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <input type="file" name="Arquivo2" size="50" />
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <input type="file" name="Arquivo3" size="50" />
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <input type="file" name="Arquivo4" size="50" />
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <input type="file" name="Arquivo5" size="50" />
                              </td>
                            </tr>
                        </table>
                        <center>
                            <div id="loading" style="display:none;margin:50px 0px 50px 0px;">
                                <b style="font-size:20px;color:#253e4f;">Aguarde até que o processo de carregamento finalize.</b>
                                <br>
                                <img src="imagens/loadingBarra.gif" border="0" id="loading" style="padding:20px 0px 20px 0px;" />
                            </div>
                        </center>
                            <input type=button name="cmdEnviar" id="cmdEnviar" value="Carregar fotos" style="margin-top:20px;" onclick="enviar();">
                    </div>
                </form>
                
            </div>
            <div id="luzRodape">
                 
            </div>
        </div>
    </div>
    <div id="fim">
        <center>
            <!--#include file="rodape.asp"-->
        </center>    
    </div>
</body>
</html>
<% end if %>
PÁGINA UPLOAD.ASP
<!--#include file="adovbs.inc"-->
<!--#include file="criptografia.asp"-->

<%
    randomize
    tam=8 'Define o tamanho da senha
    md=md5(now())
    aleat=Int(22-tam*Rnd)+1
    codigoAleatorio=mid(md, aleat, tam)
%>
<%'###### início loop SaFileUp componente##########################################################%>

<%
    
    'Server.ScriptTimeout = 360
    

    Dim oFileUp
    Dim strFormElement
    Dim strSubItem

    Dim sCaminho


    '--- Instantiate the FileUp object
    Set oFileUp = Server.CreateObject("Persits.Upload.1")
    
    oFileUp.OverwriteFiles = False
    oFileUp.SetMaxSize 99999999
    Count = oFileUp.Save("e:\home\web\imagens\fotos\")


    For Each File in oFileUp.Files

                

'######### início do registro na Base de Dados, dentro do loop do script de upload   ##############


nome_original = codigoAleatorio & "_" & File.Filename
nome_arquivo = File.FileName
     
id= request.QueryString("id")%> 



<%'#################  criando a miniatura para o thumbnail ASPJPG  ################################%>



<% 
' Create instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")
' Open source image
Jpeg.Open "e:\home\web\imagens\fotos\" & nome_arquivo &""

' New width
L = 600

' Resize, preserve aspect ratio
If Jpeg.OriginalWidth > jpeg.OriginalHeight Then
   Jpeg.Width = L
   Jpeg.Height = jpeg.OriginalHeight * L / jpeg.OriginalWidth
Else
   Jpeg.Height = L
   Jpeg.Width = jpeg.OriginalWidth * L / jpeg.OriginalHeight
End If

'Esse método é opcional, usado para melhorar o visual da imagem 
'Jpeg.Sharpen 1, 150

Jpeg.Quality = 100

' create thumbnail and save it to disk
Jpeg.Save "e:\home\web\imagens\thumbs\" & codigoAleatorio & "_" & nome_arquivo &""

%> 

<%Set Jpeg = Nothing%> 


<% 
' Create instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")
' Open source image
Jpeg.Open "e:\home\web\imagens\fotos\" & nome_arquivo &""

' New width
L = 600
' Resize, preserve aspect ratio
If Jpeg.OriginalWidth > jpeg.OriginalHeight Then
   Jpeg.Width = L
   Jpeg.Height = jpeg.OriginalHeight * L / jpeg.OriginalWidth
Else
   Jpeg.Height = L
   Jpeg.Width = jpeg.OriginalWidth * L / jpeg.OriginalHeight
End If

'Esse método é opcional, usado para melhorar o visual da imagem 
'Jpeg.Sharpen 1, 150

Jpeg.Quality = 100
jpeg.Adjust 3, -1
jpeg.Adjust 1, 0.2

' create thumbnail and save it to disk
Jpeg.Save "e:\home\web\imagens\thumbs\pb_" & codigoAleatorio & "_" & nome_arquivo &""

%> 

<%Set Jpeg = Nothing%> 


<% 
' Create instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")
' Open source image
Jpeg.Open "e:\home\web\imagens\fotos\" & nome_arquivo &""

' New width
L = 1000

' Resize, preserve aspect ratio
If Jpeg.OriginalWidth < 1000 Then

ElseIf Jpeg.OriginalWidth > jpeg.OriginalHeight Then
   Jpeg.Width = L
   Jpeg.Height = jpeg.OriginalHeight * L / jpeg.OriginalWidth
Else
   Jpeg.Height = L
   Jpeg.Width = jpeg.OriginalWidth * L / jpeg.OriginalHeight
End If

'Esse método é opcional, usado para melhorar o visual da imagem 
'Jpeg.Sharpen 1, 150

Jpeg.Quality = 100

X = Jpeg.Width - 300    
Y = Jpeg.Height - 200

'Jpeg.Canvas.DrawPNG X, Y, "e:\home\web\sistema\imagens\Sistema.png"

Jpeg.Canvas.Font.Color = &HFFFFFFF
Jpeg.Canvas.Font.Family = "Arial"
Jpeg.Canvas.Font.Size = 14
Jpeg.Canvas.Font.Bold = True
Jpeg.Canvas.Font.ShadowColor = &H000000
Jpeg.Canvas.Font.ShadowXoffset = 1
Jpeg.Canvas.Font.ShadowYoffset = 1
Jpeg.Canvas.Font.Quality = 1 


Dados = "DRIVER={Microsoft Access Driver (*.mdb)}; " & "DBQ=" & server.mappath("dados.mdb")

sqlstmtConfig = "SELECT * FROM configuracoes where id=1"
Set rsConfig = Server.CreateObject("ADODB.Recordset")
rsConfig.Open sqlstmtConfig, Dados

enderecoSite = rsConfig("enderecoSite")

Set rsConfig = nothing

'Jpeg.Canvas.Print 10, 10, "© " & Year(Date) & " " & enderecoSite

' create thumbnail and save it to disk
Jpeg.Save "e:\home\web\imagens\fotos\" & codigoAleatorio & "_" & nome_arquivo &""

%> 

<%Set Jpeg = Nothing%>

<%'###########################################  FIM ASPJPG  #######################################%>


<%
ConnString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=e:\home\web\sistema\dados.mdb;" 
Set Conn = Server.CreateObject("ADODB.Connection") 
Conn.Open ConnString 

set insertSet = Server.CreateObject("ADODB.Recordset")
insertSet.Open "fotos", Conn,_
adOpenStatic, adCmdTable

 insertSet.AddNew
 insertSet("idAlbum") = id
 insertSet("foto") = codigoAleatorio & "_" & nome_arquivo
 insertSet("thumb") = codigoAleatorio & "_" & nome_arquivo
 insertSet.update

insertSet.close
set insertSet = Nothing

%>
<%
set RS = nothing
Conn.close

%>        

<%

    Next        
    '--- Dereference FileUp
    Set oFileUp = Nothing
'####### FIM do SaFileUp componente   #########################################################

if nome_arquivo = "" then
    
else
    Set ObjFSO = Server.CreateObject("Scripting.FileSystemObject")
    ObjFSO.DeleteFile "e:\home\web\imagens\fotos\"&nome_arquivo&" "
    Set ObjFSO = Nothing
end if

%>

<%
    id= request.QueryString("id")
    album= request.QueryString("album") 
    response.Redirect("albumDetalhe.asp?album="&album&"&id="&id&"")
%>

CAMPOS DENTRO DA TABELA :

id, idAlbum , Foto , thumb

Desde já agradeço!

obg

Edited by Guilherme S
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...