Originariamente inviato da optime
vediamo il codice...
Giustissimo... allora, questo è il form per modificare i campi che ovviamente porta i campi file vuoti
codice:
<FORM ACTION="SuccessoModifica.asp?Id=<%=Rs("Id")%>" METHOD="Post" enctype="multipart/form-data">
<table width="80%" border="1" align="center">
<tr>
<td colspan="2" align="center" class="big">Modifica Automobili</td>
</tr>
<tr>
<td width="50%"></td>
<td width="50%"></td>
</tr>
<tr>
<td>Marca: </td>
<td><label>
<%
Set rsMarche = Server.CreateObject("ADODB.RecordSet")
sql = "SELECT * FROM Marche ORDER By Marche ASC"
rsMarche.Open sql, Conn, 3, 3
%>
<select name="Marche" id="Marche">
<%
Do Until RsMarche.EOF
%>
<option value="<%=RsMarche("IdMarche")%>"<%if RsMarche("IdMarche") = Rs("IdMarche") then%> selected="selected"<%end if%>><%=RsMarche("Marche")%></option>
<%
RsMarche.MoveNext
Loop
%>
</select>
</label></td>
</tr>
<tr>
<td>Alimentazione:</td>
<td><label>
<select name="Alimentazioni" id="Alimentazioni">
<%
Do Until RsAlimentazioni.EOF
%>
<option value="<%=RsAlimentazioni("IdAlimentazioni")%>"<%if RsAlimentazioni("IdAlimentazioni") = Rs("IdAlimentazioni") then%> selected="selected"<%end if%>><%=RsAlimentazioni("Alimentazioni")%></option>
<%
RsAlimentazioni.MoveNext
Loop
%>
</select>
</label></td>
</tr>
<tr>
<td>Categoria:</td>
<td><label>
<select name="Categorie" id="Categorie">
<%
Do Until RsCategorie.EOF
%>
<option value="<%=RsCategorie("IdCategorie")%>"<%if RsCategorie("IdCategorie") = Rs("IdCategorie") then%> selected="selected"<%end if%>><%=RsCategorie("Categorie")%></option> <%
RsCategorie.MoveNext
Loop
%>
</select>
</label></td>
</tr>
<tr>
<td>Stato:</td>
<td><label>
<select name="Stati" id="Stati">
<%
Do Until RsStati.EOF
%>
<option value="<%=RsStati("IdStati")%>"<%if RsStati("IdStati") = Rs("IdStati") then%> selected="selected"<%end if%>><%=RsStati("Stati")%></option>
<%
RsStati.MoveNext
Loop
%>
</select>
</label></td>
</tr>
<tr>
<td>Modello:</td>
<td><label>
<input type="text" name="Modello" id="Modello" value="<%=Rs("Modello")%>">
</label></td>
</tr>
<tr>
<td>Immatricolazione:</td>
<td><label>
<input type="text" name="Immatricolazione" id="Immatricolazione" value="<%=Rs("Immatricolazione")%>">
</label></td>
</tr>
<tr>
<td>Prezzo:</td>
<td><label>
<input type="text" name="Prezzo" id="Prezzo" value="<%=Rs("Prezzo")%>">
</label></td>
</tr>
<tr>
<td>Chilometri:</td>
<td><label>
<input type="text" name="Km" id="Km" value="<%=Rs("Km")%>">
</label></td>
</tr>
<tr>
<td>Descrizione:</td>
<td><label>
<textarea name="Descrizione" id="Descrizione" cols="45" rows="5"><%=Rs("Descrizione")%></textarea>
</label></td>
</tr>
<tr> </tr>
<tr>
<td>Immagine 1:</td>
<td><input type="file" name="img"/></td>
</tr>
<tr>
<td>Immagine 2:</td>
<td><input type="file" name="img1"/></td>
</tr>
<tr>
<td>Immagine 3:</td>
<td><input type="file" name="img2"/></td>
</tr>
<tr>
<td>Immagine 4:</td>
<td><input type="file" name="img3"/></td>
</tr>
<tr>
<td>Immagine 5:</td>
<td><input type="file" name="img4"/></td>
</tr>
<tr>
<td>Immagine 6:</td>
<td><input type="file" name="img5"/></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2" align="center"><INPUT NAME="Enter" TYPE="Submit" value="Invia"></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2" align="center">Torna alla gestione</td>
</tr>
</table>
</FORM>
Mentre quest'altro è quello che esegue l'UPDATE (uso lo script di Baol)
codice:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.charset="utf-8"%>
<%
Dim oUpload
Set oUpload = new cUpload
oUpload.AutoRename = True
oUpload.Overwrite = False
oUpload.SetPath "files\" 'Impostazione del percorso
oUpload.Load
While Not oUpload.EOF
oUpload.Save()
Select Case lCase(oUpload.Files("InputName"))
Case "img"
FileName_img = oUpload.GetFileName()
Case "img1"
FileName_img1 = oUpload.GetFileName()
Case "img2"
FileName_img2 = oUpload.GetFileName()
Case "img3"
FileName_img3 = oUpload.GetFileName()
Case "img4"
FileName_img4 = oUpload.GetFileName()
Case "img5"
FileName_img5 = oUpload.GetFileName()
End Select
oUpload.MoveNext
Wend
Sql = "SELECT * FROM qryAutomobili WHERE Id=" & Request.QueryString("Id")
Set Rs=server.CreateObject("ADODB.Recordset")
Rs.Open Sql,Conn,3,3
Rs("IdMarche") = oUpload.Form("Marche")
Rs("IdAlimentazioni") = oUpload.Form("Alimentazioni")
Rs("IdCategorie") = oUpload.Form("Categorie")
Rs("IdStati") = oUpload.Form("Stati")
Rs("Modello") = oUpload.Form("Modello")
Rs("Immatricolazione") = oUpload.Form("Immatricolazione")
Rs("Prezzo") = oUpload.Form("Prezzo")
Rs("Km") = oUpload.Form("Km")
Rs("Descrizione") = oUpload.Form("Descrizione")
Rs("img") = FileName_img
Rs("img1") = FileName_img1
Rs("img2") = FileName_img2
Rs("img3") = FileName_img3
Rs("img4") = FileName_img4
Rs("img5") = FileName_img5
Rs.update
Rs.Close
Set Rs = Nothing
%>
Grazie ancora