conceptmgt
IS-IT--Management
Hi
This has been annoying me for ages. I have a form with 2 images. When someone updates the second image and not the first it replaces the first image with the new second image.
It is because I use For Each File In Uploader.Files.Items has anyone got idea how I could get around this.
Thanks
Gary
'---------------The Form-------------------------
<%
If not rs("imagepath1"
="" then
response.write("<img src="" else
response.write("<img src=Images/Image.gif width=90 height=90>"
end if
response.write("<input type=hidden name=imagepath1 value="&rs("imagepath1"
&">"
%>
<input name="image1" type="file" size="10">
'---------------Get Images-----------------------
For Each File In Uploader.Files.Items
File.SaveToDisk "C:\\Inetpub\\
ReDim Preserve arrImages(i)
arrImages(i) = File.FileName
i = i + 1
delFileName = Uploader.form("imagePath"&i)
If not delFileName = "" then
Set objFSO = CreateObject("Scripting.FileSystemObject"
objFSO.DeleteFile("c:/inetpub/ Set objFSO = Nothing
End if
Next
'---------------Update Table-----------------------
Set Conn = Server.CreateObject("ADODB.Connection"
Set RS = Server.CreateObject("ADODB.Recordset"
Conn.open strconnect
strsql = "UPDATE Newsletter"
strsql = strsql + " SET NewsletterName='"& newsName &"', emailFrom='"& Uploader.Form("from"
&"'"
k = 0
For Each File In Uploader.Files.Items
strsql = strsql + ", imagepath"&k+1&"='"&arrImages(k)&"'"
k=k+1
Next
strsql = strsql + " Where newsletterID LIKE "&newsletterID&""
Set RS = Conn.Execute(strsql)
This has been annoying me for ages. I have a form with 2 images. When someone updates the second image and not the first it replaces the first image with the new second image.
It is because I use For Each File In Uploader.Files.Items has anyone got idea how I could get around this.
Thanks
Gary
'---------------The Form-------------------------
<%
If not rs("imagepath1"
response.write("<img src="" else
response.write("<img src=Images/Image.gif width=90 height=90>"
end if
response.write("<input type=hidden name=imagepath1 value="&rs("imagepath1"
%>
<input name="image1" type="file" size="10">
'---------------Get Images-----------------------
For Each File In Uploader.Files.Items
File.SaveToDisk "C:\\Inetpub\\
ReDim Preserve arrImages(i)
arrImages(i) = File.FileName
i = i + 1
delFileName = Uploader.form("imagePath"&i)
If not delFileName = "" then
Set objFSO = CreateObject("Scripting.FileSystemObject"
objFSO.DeleteFile("c:/inetpub/ Set objFSO = Nothing
End if
Next
'---------------Update Table-----------------------
Set Conn = Server.CreateObject("ADODB.Connection"
Set RS = Server.CreateObject("ADODB.Recordset"
Conn.open strconnect
strsql = "UPDATE Newsletter"
strsql = strsql + " SET NewsletterName='"& newsName &"', emailFrom='"& Uploader.Form("from"
k = 0
For Each File In Uploader.Files.Items
strsql = strsql + ", imagepath"&k+1&"='"&arrImages(k)&"'"
k=k+1
Next
strsql = strsql + " Where newsletterID LIKE "&newsletterID&""
Set RS = Conn.Execute(strsql)