• User Newbie

    Upload baol aggiornare foto nel db e nella cartella

    Salve a tutti,
    ho implementato l'upload di baol su un sito inserendo anche il salvataggio nome immagine in campi db access.
    Ora avrei una domanda: come faccio ad adattare il codice dell'upload per sostituire\aggiornare le immagini precedentemente uploadate nei campi del db?
    Riesco tranquillamente ad aggiornare gli altri campi ma ho problemi con le immagini.

    Spero di essere stato chiaro e sopratutto di trovare qualche anima pia disposta ad aiutarmi.

    Grazie.


  • User Newbie

    Il codice che ho utilizzato è questo

    <%
    age= Trim(Request.QueryString("age"))
    
    dim conn2
    set conn2=server.CreateObject("ADODB.Connection")
    Conn2.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& server.MapPath("/mdb-database/immobile.mdb")
    
    sql="select * from da_vendere where codice='"&age&"'"
    set rs=conn2.execute(sql)
    %>
    <!--#include file="upload.asp"-->
    <%
    	If Request.QueryString("Save")="1" then
    		Dim oUpload
    		Set oUpload = new cUpload
    		oUpload.AutoRename = True
    		oUpload.Overwrite = False
    		oUpload.SetPath "public/Immobili" 'Impostazione del percorso
    		oUpload.Load
    		While Not oUpload.EOF
    			oUpload.Save()
    			Select Case lCase(oUpload.Files("InputName"))
    			Case "image1"
    					FileName_image1= oUpload.GetFileName()
    			Case "image2"
    					FileName_image2= oUpload.GetFileName()
    			Case "image3"
    					FileName_image3= oUpload.GetFileName()
    			Case "image4"
    					FileName_image4= oUpload.GetFileName()
    			Case "image5"
    					FileName_image5= oUpload.GetFileName()
    			Case "image6"
    					FileName_image6= oUpload.GetFileName()
    			Case "image7"
    					FileName_image7= oUpload.GetFileName()
    			Case "image8"
    					FileName_image8= oUpload.GetFileName()
    			Case "image9"
    					FileName_image9= oUpload.GetFileName()
    			Case "image10"
    					FileName_image10= oUpload.GetFileName()
    			Case "image11"
    					FileName_image11= oUpload.GetFileName()
    			Case "image12"
    					FileName_image12= oUpload.GetFileName()
    			Case "image13"
    					FileName_image13= oUpload.GetFileName()
    			Case "image14"
    					FileName_image14= oUpload.GetFileName()
    			Case "image15"
    					FileName_image15= oUpload.GetFileName()
    			Case "image16"
    					FileName_image16= oUpload.GetFileName()
    			Case "image17"
    					FileName_image17= oUpload.GetFileName()
    			Case "image18"
    					FileName_image18= oUpload.GetFileName()
    			Case "image19"
    					FileName_image19= oUpload.GetFileName()
    			Case "image20"
    					FileName_image20= oUpload.GetFileName()
    						End Select
    			oUpload.MoveNext
    		Wend			
    		Set Conn = Server.CreateObject("ADODB.Connection")
      Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/mdb-database/Immobile.mdb")
      Set Rs=server.CreateObject("ADODB.Recordset")
      id= oUpload.Form("id")
      SQL="select * from da_vendere where id= "& id &";"
      rs.open SQL, conn, 3, 3
      Rs.Update
    
    		Rs("localita")	= oUpload.Form("localita")
    		Rs("codice")		= oUpload.Form("codice")
    		Rs("contratto")	= oUpload.Form("contratto")
    		Rs("prezzo")		= oUpload.Form("prezzo")
    		Rs("vani")	= oUpload.Form("vani")
    		Rs("provincia")		= oUpload.Form("mq")
    		Rs("comune")	= oUpload.Form("comune")
    		Rs("tipologia")		= oUpload.Form("tipologia")
    		Rs("piano")	= oUpload.Form("piano")
    		Rs("anno")		= oUpload.Form("anno")
    		Rs("postoauto")	= oUpload.Form("postoauto")
    		Rs("cucina")		= oUpload.Form("cucina")
    		Rs("letti")	= oUpload.Form("letti")
    		Rs("bagni")		= oUpload.Form("bagni")
    		Rs("cantina")	= oUpload.Form("cantina")
    		Rs("terrazzi")		= oUpload.Form("terrazzi")
    		Rs("mq")	= oUpload.Form("mq")
    		Rs("zonagiorno")		= oUpload.Form("zonagiorno")
    		Rs("angolocottura")	= oUpload.Form("angolocottura")
    		Rs("letti")		= oUpload.Form("letti")
    		Rs("giardino")	= oUpload.Form("giardino")
    		Rs("box")		= oUpload.Form("box")
    		Rs("piscina")	= oUpload.Form("piscina")
    		Rs("descrizione")		= oUpload.Form("descrizione")
    		
    		Rs("image1")	= FileName_image1
    		if (rs("Image2")<>" ") then
    		Rs("image2")	= FileName_image2
    		else
    		Rs("image2")=Rs("Image2")
    		end if
    		Rs("image3")	= FileName_image3
    		Rs("image4")	= FileName_image4
    		Rs("image5")	= FileName_image5
    		Rs("image6")	= FileName_image6
    		Rs("image7")	= FileName_image7
    		Rs("image8")	= FileName_image8
    		Rs("image9")	= FileName_image9
    		Rs("image10")	= FileName_image10
    		Rs("image11")	= FileName_image11
    		Rs("image12")	= FileName_image12
    		Rs("image13")	= FileName_image13
    		Rs("image14")	= FileName_image14
    		Rs("image15")	= FileName_image15
    		Rs("image16")	= FileName_image16
    		Rs("image17")	= FileName_image17
    		Rs("image18")	= FileName_image18
    		Rs("image19")	= FileName_image19
    		Rs("image20")	= FileName_image20
    				
    		Rs.update
      Rs.Close
      Conn.Close
      Set Rs = Nothing
      Set Conn=Nothing    
      Set oUpload = Nothing
    
    	End if
    %>
    	
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Modifica dati immobile</title>
    <link rel="stylesheet" href="../sh.css" type="text/css">
    </head>
    
    <body bgcolor="#FFFFFF">
    
    <div align="center">
      <center>
      <table border="0" cellpadding="0" cellspacing="0" width="700" bgcolor="#FFFFFF" height="501" background="sfondo1.jpg" style="border-collapse: collapse" bordercolor="#111111">
        <tr>
          <td height="58" colspan="2" width="700">
    <p align="center" style="margin-top: 1; margin-bottom: 1"><u><b> <font face="Verdana" size="4" color="#0000FF">Pannello 
              Modifica Dati Immobile</font></b></u></td>
        </tr>
      </center>
        <tr>
          <td background="../img/sfondo.gif" height="389" colspan="2">
            <blockquote>
              <p align="justify" style="margin-top: 0; margin-bottom: 0"><font size="2"> 
                Da questo pannello è possibile modificare i dati dell'Immobile selezionato. 
                I campi contrassegnati con <font color="#FF0000">*</font> sono obbligatori 
                . </font>
    <p align="justify" style="margin-top: 0; margin-bottom: 0">&nbsp;</blockquote>
            <form name="form1" method="post" enctype="multipart/form-data" action="?save=1"><div align="left">
              <input type="hidden" name="id" value="<%=rs("id")%>">                  
                <table border="0" cellpadding="0" cellspacing="0" width="700" height="521" style="border-collapse: collapse" bordercolor="#111111">
                  <!--DWLayoutTable-->
                  <tr> 
                    <td width="114" valign="top" align="right" height="31"> <p align="right"><b>Localita:&nbsp; 
                        </b> </td>
                    <td width="238" valign="top"> <p align="left"> 
                        <input type="text" name="localita" size="32" value="<%=rs("localita")%>" id="localita">
                        <font color="#FF0000">*</font> </td>
                    <td colspan="2" align="right" valign="top"> <p align="right"><b>Cucina:&nbsp; 
                        </b> </td>
                    <td width="213" valign="top"><b><font color="#FF0000"> 
                      <input type="text" name="cucina" size="32" value="<%=rs("cucina")%>" id="cucina">
                      </font></b></td>
                    <td width="11"></td>
                  </tr>
                  <tr> 
                    <td valign="top" align="right" height="31"><b>Codice:&nbsp;&nbsp; 
                      </b></td>
                    <td valign="top"> <input type="text" name="codice" size="32" value="<%=rs("codice")%>" id="codice"> 
                      <font color="#FF0000">*</font></td>
                    <td colspan="2" align="right" valign="top"><b>Letto: &nbsp; </b></td>
                    <td valign="top"><b><font color="#FF0000"> 
                      <input type="text" name="letti" size="32" value="<%=rs("letti")%>" id="letti">
                      </font></b></td>
                    <td></td>
                  </tr>
                  <tr> 
                    <td valign="top" align="right" height="31"><b>Contratto:&nbsp;&nbsp; 
                      </b></td>
                    <td valign="top"> <input type="text" name="contratto" size="32" value="<%=rs("contratto")%>" id="contratto"> 
                    </td>
                    <td colspan="2" align="right" valign="top"><b>Bagno: &nbsp; </b></td>
                    <td valign="top"><b><font color="#FF0000"> 
                      <input type="text" name="bagni" size="32" value="<%=rs("bagni")%>" id="bagni">
                      </font></b></td>
                    <td></td>
                  </tr>
                  <tr> 
                    <td valign="top" align="right" height="31"><b> Prezzo:&nbsp;&nbsp; 
                      </b></td>
                    <td valign="top"> <input type="text" name="prezzo" size="32" value="<%=rs("prezzo")%>" id="prezzo"> 
                      <font color="#FF0000">*</font></td>
                    <td colspan="2" align="right" valign="top"><b>Cantina: &nbsp; 
                      </b></td>
                    <td valign="top"><b><font color="#FF0000"> 
                      <input type="text" name="cantina" size="32" value="<%=rs("cantina")%>" id="cantina">
                      </font></b></td>
                    <td></td>
                  </tr>
                  <tr> 
                    <td valign="top" align="right" height="30"><b>Vani:&nbsp;&nbsp; 
                      </b></td>
                    <td valign="top"> <input type="text" name="vani" size="32" value="<%=rs("vani")%>" id="vani"> 
                    </td>
                    <td colspan="2" align="right" valign="top"><b>Terrazzo: &nbsp; 
                      </b></td>
                    <td valign="top"><b><font color="#FF0000"> 
                      <input type="text" name="terrazzi" size="32" value="<%=rs("terrazzi")%>" id="terrazzi">
                      </font></b></td>
                    <td></td>
                  </tr>
                  <tr> 
                    <td valign="top" align="right" height="31"><b>Provincia:&nbsp;&nbsp; 
                      </b></td>
                    <td valign="top"> <input type="text" name="provincia" size="32" value="<%=rs("provincia")%>" id="provincia"> 
                    </td>
                    <td colspan="2" align="right" valign="top"> <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                      Mq: &nbsp; </b></td>
                    <td valign="top"> <b><font color="#FF0000"> 
                      <input type="text" name="mq" size="32" value="<%=rs("mq")%>" id="mq">
                      </font></b></td>
                    <td></td>
                  </tr>
                  <tr> 
                    <td valign="top" align="right" height="29"><b>Comune:&nbsp;&nbsp; 
                      </b></td>
                    <td valign="top"> <input type="text" name="comune" size="32" value="<%=rs("comune")%>" id="comune"> 
                    </td>
                    <td colspan="2" align="right" valign="top" nowrap> <p align="right"><b>Zona 
                        Giorno:</b>&nbsp; </td>
                    <td valign="top"><b><font color="#FF0000"> 
                      <input type="text" name="zonagiorno" size="32" value="<%=rs("zonagiorno")%>" id="zonagiorno">
                      </font></b></td>
                    <td></td>
                  </tr>
                  <tr> 
                    <td height="31" align="right" valign="top"><b>Piano: &nbsp;</b></td>
                    <td valign="top"> <input type="text" name="piano" size="32" value="<%=rs("piano")%>" id="piano"> 
                    </td>
                    <td colspan="2" align="right" valign="top"><b>Giardino: &nbsp; 
                      </b> </td>
                    <td valign="top"><b><font color="#FF0000"> 
                      <input type="text" name="giardino" size="32" value="<%=rs("giardino")%>" id="giardino">
                      </font></b></td>
                    <td></td>
                  </tr>
                  <tr> 
                    <td height="31" align="right" valign="top"><b>Anno: &nbsp;</b></td>
                    <td valign="top"> <input type="text" name="anno" size="32" value="<%=rs("anno")%>" id="anno"> 
                    </td>
                    <td colspan="2" align="right" valign="top">&nbsp;&nbsp; <b>Box: 
                      &nbsp; </b></td>
                    <td valign="top"> <input type="text" name="box" size="32" value="<%=rs("box")%>" id="box"> 
                    </td>
                    <td></td>
                  </tr>
                  <tr> 
                    <td height="31" align="right" valign="top"><b>Posto auto : &nbsp;</b></td>
                    <td align="left" valign="top"> <input type="text" name="postoauto" size="32" value="<%=rs("postoauto")%>" id="postoauto"> 
                    </td>
                    <td colspan="2" align="right" valign="top">&nbsp;&nbsp; <b>Piscina: 
                      &nbsp; </b></td>
                    <td valign="top"> <input type="text" name="box" size="32" value="<%=rs("piscina")%>" id="piscina"> 
                    <td>&nbsp;</td>
                  </tr>
                  <tr> 
                    <td height="31" align="right" valign="top"><b>&nbsp;Tipologia:&nbsp;&nbsp; 
                      </b></td>
                    <td valign="top"> <input type="text" name="tipologia" size="32" value="<%=rs("tipologia")%>" id="tipologia"> 
                      <font color="#FF0000">*</font></td>
                    <td colspan="2" align="right" valign="top"><b>An. Cottura: &nbsp; 
                      </b> </td>
                    <td valign="top"><b><font color="#FF0000"> 
                      <input type="text" name="angolocottura" size="32" value="<%=rs("angolocottura")%>" id="angolocottura">
                      </font></b></td>
                    <td></td>
                  </tr>
                  <tr> 
                    <td height="150" align="right" valign="top"><b>Descrizione : &nbsp;</b></td>
                    <td colspan="2" align="left" valign="top"> <textarea rows="8" name="descrizione" cols="38"><%=rs("descrizione")%></textarea> 
                    </td>
                    <td width="99"><!--DWLayoutEmptyCell-->&nbsp;</td>
                    <td><!--DWLayoutEmptyCell-->&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr> 
                      <td height="25" align="right" valign="top"><b>Img2: &nbsp;</b></td>
                      <td colspan="2" align="left" valign="top"><font color="#000080" face="Verdana">
                        <input name="image2" type="file" id="image2" >
                        </font> 
                      </td>
                      <td width="99"><b>Img3 :</b></td>
                      <td><font color="#000080" face="Verdana">
                        <input name="image3" type="file" id="image3" >
                        </font></td>
                      <td>&nbsp;</td>
                    </tr>
    				<tr> 
                      <td height="24" align="right" valign="top"><b>Img4: &nbsp;</b></td>
                      <td colspan="2" align="left" valign="top"><font color="#000080" face="Verdana">
                        <input name="image4" type="file" id="image4" >
                        </font> 
                      </td>
                      <td width="99"><b>Img5 :</b></td>
                      <td><font color="#000080" face="Verdana">
                        <input name="image5" type="file" id="image5" >
                        </font></td>
                      <td>&nbsp;</td>
                    </tr>
    				<tr> 
                      <td height="24" align="right" valign="top"><b>Img6: &nbsp;</b></td>
                      <td colspan="2" align="left" valign="top"><font color="#000080" face="Verdana">
                        <input name="image6" type="file" id="image6" >
                        </font> 
                      </td>
                      <td width="99"><b>Img7 :</b></td>
                      <td><font color="#000080" face="Verdana">
                        <input name="image7" type="file" id="image7" >
                        </font></td>
                      <td>&nbsp;</td>
                    </tr>
    				<tr> 
                      <td height="24" align="right" valign="top"><b>Img8: &nbsp;</b></td>
                      <td colspan="2" align="left" valign="top"><font color="#000080" face="Verdana">
                        <input name="image8" type="file" id="image8" >
                         </font> 
                      </td>
                      <td width="99"><b>Img9 :</b></td>
                      <td><font color="#000080" face="Verdana">
                        <input name="image9" type="file" id="image9" >
                        </font></td>
                      <td>&nbsp;</td>
                    </tr>
    				<tr> 
                      <td height="24" align="right" valign="top"><b>Img10: &nbsp;</b></td>
                      <td colspan="2" align="left" valign="top"><font color="#000080" face="Verdana">
                        <input name="image10" type="file" id="image10" >
                        </font> 
                      </td>
                      <td width="99"><b>Img11 :</b></td>
                      <td><font color="#000080" face="Verdana">
                        <input name="image11" type="file" id="image11" >
                        </font></td>
                      <td>&nbsp;</td>
                    </tr>
    				<tr> 
                      <td height="24" align="right" valign="top"><b>Img12: &nbsp;</b></td>
                      <td colspan="2" align="left" valign="top"><font color="#000080" face="Verdana">
                        <input name="image12" type="file" id="image12" >
                        </font> 
                      </td>
                      <td width="99"><b>Img13 :</b></td>
                      <td><font color="#000080" face="Verdana">
                        <input name="image13" type="file" id="image13" >
                        </font></td>
                      <td>&nbsp;</td>
                    </tr>
    				<tr> 
                      <td height="24" align="right" valign="top"><b>Img14: &nbsp;</b></td>
                      <td colspan="2" align="left" valign="top"><font color="#000080" face="Verdana">
                        <input name="image14" type="file" id="image14" >
                        </font> 
                      </td>
                      <td width="99"><b>Img15 :</b></td>
                      <td><font color="#000080" face="Verdana">
                        <input name="image15" type="file" id="image15" >
                        </font></td>
                      <td>&nbsp;</td>
                    </tr>
    				<tr> 
                      <td height="24" align="right" valign="top"><b>Img16: &nbsp;</b></td>
                      <td colspan="2" align="left" valign="top"><font color="#000080" face="Verdana">
                        <input name="image16" type="file" id="image16" >
                        </font> 
                      </td>
                      <td width="99"><b>Img17 :</b></td>
                      <td><font color="#000080" face="Verdana">
                        <input name="image17" type="file" id="image17" >
                        </font></td>
                      <td>&nbsp;</td>
                    </tr>
    				<tr> 
                      <td height="24" align="right" valign="top"><b>Img18: &nbsp;</b></td>
                      <td colspan="2" align="left" valign="top"><font color="#000080" face="Verdana">
                        <input name="image18" type="file" id="image18" >
                        </font> 
                      </td>
                      <td width="99"><b>Img19 :</b></td>
                      <td><font color="#000080" face="Verdana">
                        <input name="image19" type="file" id="image19" >
                        </font></td>
                      <td>&nbsp;</td>
                    </tr>
    				<tr> 
                      <td height="24" align="right" valign="top"><b>Img20: &nbsp;</b></td>
                      <td colspan="2" align="left" valign="top"><font color="#000080" face="Verdana">
                        <input name="image20" type="file" id="image20" >
                        </font> 
                      </td>
                      <td width="99"><b>Img1:</b></td>
                      <td><input name="image1" type="file" id="image1" ></td>
                      <td>&nbsp;</td>
                    </tr>
    			  <table width="700" height="325" border="0" cellpadding="0" cellspacing="0" bordercolor="#111111" style="border-collapse: collapse" dwcopytype="CopyTableCell">
                  </table>
                  <tr> 
                    <td height="33"></td>
                    <td></td>
                    <td colspan="2">&nbsp;&nbsp; <input type="submit" value="invia i dati" name="pulsante" style="float: right"></td>
                    <td align="center"> <p align="center">&nbsp; 
                        <input type="reset" value="Reimposta" name="reset" style="float: left">
                    </td>
                    <td></td>
                  </tr>
                  <tr>
                    <td height="1"></td>
                    <td></td>
                    <td width="25"></td>
                    <td></td>
                    <td></td>
                    <td></td>
                  </tr>
                </table>
            </div>
            </form>
            </td>
        </tr>
        <tr>
          <td height="35" valign="bottom" width="270">&nbsp;</td>
          <td height="35" valign="bottom" width="430">&nbsp;</td>
        </tr>
        <tr>
          <td height="19" valign="bottom" width="700" colspan="2">
          <p align="center">&nbsp; [
    <a href="Partners.asp">Indietro</a> ]</td>
        </tr>
      </table>
    </div>
    
    </body>
    </html>
    
    
    

    Spero che qualcuno mi dia una mano:?