Questo è il codice completo che sto utilizzando:
codice:
<%@LANGUAGE="VBSCRIPT"%>
<%server.scripttimeout = 2000
session.timeout=60
if (session("autorizzato") = "SI") then
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
Function RedimFoto(nome1)
Dim xml,tmpResult,url
Set xml = Server.CreateObject("Microsoft.Xmlhttp")
URL = "http://www.xxx.it/xxx/area%20riservata/ridimensiona-prodotti.aspx?foto1=" & nome1
xml.open "GET", URL ,false
xml.send()
tmpResult = xml.ResponseText
Set xml = nothing
if Instr(1,tmpResult,"Errore") <> 0 then
'Il ridimensionamento non è andato a buon fine
RedimFoto = false
else
RedimFoto = true
end if
End Function
dim co
set co = server.createObject("ADODB.Connection")
co.Open "Driver={MySQL ODBC 3.51 Driver};server=xxx;port=3306;Database=xxx;UID=xxx;PWD=xxx"
dim rsnumerofoto
set rsnumerofoto = server.createObject("ADODB.Recordset")
strqnumerofoto = "SELECT * from numerofoto where id=1"
rsnumerofoto.Open strqnumerofoto,co,2,3
strqsommanumerofoto = "UPDATE numerofoto SET numero=" & (Cint(rsnumerofoto("numero")) + 2) & " WHERE id=1"
co.execute (strqsommanumerofoto)
numerofoto1 = (Cint(rsnumerofoto("numero")) + 1)
numerofoto2 = (Cint(rsnumerofoto("numero")) + 2)
co.close
set co = nothing
dominio = "http://www.xxx.it/xxx/"
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
Dim oUpload
newRecord = false
Set oUpload = new cUpload
With oUpload
.EnabledAspUpload = False
.EnabledImageSize = true
.EnabledLog = False
.AutoRename = False
.Overwrite = False
.SetPath "/public/foto/"
.Load()
.movefirst()
Campoabilitato = .form("campoabilitato")
Ccategoria = .form("campocategoria")
Ctitolo = .form("campotitolo")
Cdescrizione = .form("campodescrizione")
Cprezzo = .form("campoprezzo")
Cfoto1 = .form("campofoto1")
Cfoto1 = .Files("Name") & "." & .Files("Ext")
Cfoto1 = numerofoto1 & "-" & Cfoto1
Cfoto2 = .form("campofoto2")
Cfoto2 = .Files("Name") & "." & .Files("Ext")
Cfoto2 = numerofoto2 & "-" & Cfoto2
.saveAs Cfoto1
.saveAs Cfoto2
end with
if campoabilitato <> "SI" then
Cabilitato = "N"
else
Cabilitato = "S"
end if
set co = server.createObject("ADODB.Connection")
co.Open "Driver={MySQL ODBC 3.51 Driver};server=xxx;port=3306;Database=xxx;UID=xxx;PWD=xxx"
dim rs
set rs = server.createObject("ADODB.Recordset")
strq = "select * from prodotticategorie order by titolo"
rs.Open strq,co,2,3
dim rs2
strq2 = "select count(*) as totrec from prodotticategorie"
set rs2 = co.execute(strq2)
totrec = Cint(rs2(0))
if totrec > 0 then
rs.movefirst
while not rs.eof
controllocategorie = rs("titolo")
controllocategorie = replace(controllocategorie," ","")
Ccategoria = replace(Ccategoria," ","")
if controllocategorie = Ccategoria then
Ccategoria = rs("id")
Ccollegamento = "CATEGORIA"
rs.movelast
end if
rs.movenext
wend
end if
strq = "INSERT INTO prodotti (abilitato,posizione,categoria,titolo,descrizione,foto1,foto2) VALUES ('"& Cabilitato & "','0','" & Ccategoria & "','" & Ctitolo & "','" & Cdescrizione & "','" & Cfoto1 & "','" & Cfoto2 & "')"
co.execute (strq)
co.close
set co = nothing
if RedimFoto(Cfoto1) then
Fso.DeleteFile Server.MapPath("/public/foto/" & Cfoto1)
Fso.DeleteFile Server.MapPath("/public/foto/" & Cfoto2)
else
Response.redirect ("aggiorna_prodotti_errore.asp")
end if
if RedimFoto(Cfoto2) then
Fso.DeleteFile Server.MapPath("/public/foto/" & Cfoto2)
Response.redirect ("aggiorna_prodotti_visualizza.asp")
else
Response.redirect ("aggiorna_prodotti_errore.asp")
end if
%>
</body>
</html>
<%
else
Response.Redirect("http://www.xxx.it/area_riservata.asp")
end if
%>
Non ho trovato una soluzione per implementare il ciclo in modo tale che funzioni l'upload di 2 fotografie con tutto il resto del codice.
Potresti dargli un occhiata e farmi sapere se e quale può essere una soluzione??
Grazie mille.