What I have here is a basic admin page where a customer can upload data to an access database.
Adding the details is fine, but when I go back to the admin area and try to edit one of the items, it shows that there is an image in the database, but as soon as I change something and then click submit the clock is lost and instead it uploads nothing and so clears the clock away in the database.
This is the area that allows me to browse to the image on the edit page
Then when submitted it goes to a new page and here is the code for that.HTML Code:<form method="post" enctype="multipart/form-data" action="manageproducts_art.asp"> <tr> <td bgcolor="#CCCCCC"><b>Current Full Length Clock Picture:</b></td> <td><strong><%=Server.HTMLEncode( artPicFull )%> </strong></td> </tr> <tr> <td bgcolor="#CCCCCC"><b>New Full Length Clock Picture:</b> </td> <td><input name="artPicFull" size="50" type="file" /></td> </tr> <input type="hidden" name="origImage" value="<%=Server.HTMLEncode( artPicFull )%>" /> <input name="catID" type="hidden" value="<%=catID%>"> <input name="updateProduct" type="hidden" value="1"> <input name="submit" type="submit" value="submit"> </form>
So just to re-cap I can upload an image first off in the add section, but then when I go to edit an item I have to find the clock again and browse to it before clicking submit otherwise I lose the clock reference in the database.HTML Code:if instr(Trim(Request.ServerVariables("HTTP_REFERER")),"addproduct_art.asp") or instr(Trim(Request.ServerVariables("HTTP_REFERER")),"updateproduct_art.asp") then Set Upload = Server.CreateObject("Persits.Upload") theCount = upload.save(server.mappath("..")&"\images\uploaded") dim arr(1), i i = 1 For Each File in Upload.Files arr(i) = File.FileName i = i + 1 Next 'Count = Upload.SaveVirtual("../upload") ' Get the form variables addProduct = TRIM (Upload.Form("addProduct")) updateProduct = TRIM (Upload.Form("updateProduct")) deleteProduct = TRIM (Upload.Form("deleteProduct")) 'response.write("delete=" & deleteProduct) delID = TRIM (Upload.Form("delID")) catID = TRIM (Upload.Form("catID")) artTitle = TRIM (Upload.Form("artTitle")) artCategory = TRIM (Upload.Form("artCategory")) artBriefDesc = TRIM (Upload.Form("artBriefDesc")) artPrice = TRIM (Upload.Form("artPrice")) artPicFull = TRIM (arr(1)) artStatus = TRIM (Upload.Form("artStatus")) artDisplay = TRIM (Upload.Form("artDisplay")) set upload = nothing 'Assign Default Values IF artTitle = "" THEN artTitle = "?????" END IF IF artCategory = "" THEN artCategory = "?????" END IF IF artBriefDesc = "" THEN artBriefDesc = "?????" END IF IF artPrice = "" THEN artPrice = "?????" END IF IF artStatus = "" THEN artStatus = "?????" END IF IF artDisplay = "" THEN artDisplay = "?????" END IF ' Add new product if artPicFull = "" then Pimage = origImage else Pimage = artPicFull end if if addProduct <> "" then strsqlM = "INSERT INTO eventDisplay " &_ "( art_Title, art_Category, art_BDescription, art_Price, art_ThumbFull, art_Status, art_Display ) VALUES (" &_ " '" & fixQuotes (artTitle ) & "', " &_ " '" & fixQuotes (artCategory ) & "', " &_ " '" & fixQuotes (artBriefDesc ) & "', " &_ " '" & fixQuotes (artPrice ) & "', " &_ " '" & fixQuotes (artPicFull ) & "', " &_ " '" & fixQuotes (artStatus ) & "', " &_ " " & fixQuotes (artDisplay ) & " )" 'rsuser.open strsql, conn On Error Resume Next ConnM.Execute strsqlM If Err <> 0 Then Response.Write "Error in query " & strsqlM Response.End End If end if %> <center> <br> <table width="600" border="1" cellpadding="4" cellspacing ="0" bgcolor="white"> <tr> <td width="161"><strong>Clock Title:</strong></td> <td width="417"><b><%=artTitle%></b> </td> </tr> <tr> <td height="29"><strong>Category: </strong></td> <td><b><%=artCategory%></b></td> </tr> <tr> <td height="29"><strong>Brief Description:</strong></td> <td><b><%=artBriefDesc%></b></td> </tr> <tr> <td height="29"><strong>Price:</strong></td> <td><b><%=artPrice%></b></td> </tr> <tr> <td height="29"><strong>Picture of full length:</strong></td> <td><b><%=Pimage%> </b></td> </tr> <tr> <td height="29"><strong>Status:</strong></td> <td><br> <b><%=artStatus%></b> </td> </tr> <tr> <td height="29"><strong>Display:</strong></td> <td><br> <b><%=artDisplay%></b> </td> </tr> <tr> <td height="29"> </td> <td><br/><span class="style2">Was added to the database</span> </td> </tr> </table> </center> <p> <% end if %> <% ' Update Product IF updateProduct <> "" THEN if artPicFull = "" then Pimage = origImage else Pimage = artPicFull end if if artTitle = "" then strsqlM = "UPDATE eventDisplay SET " &_ "art_Category='" & fixQuotes( artCategory ) & "', " &_ "art_BDescription='" & fixQuotes( artBriefDesc ) & "', " &_ "art_Price='" & fixQuotes( artPrice ) & "', " &_ "art_ThumbFull='" & fixQuotes( Pimage ) & "', " &_ "art_Status='" & fixQuotes( artStatus ) & "', " &_ "art_Display=" & artDisplay & " " &_ " WHERE " &_ "cat_ID=" & catID else strsqlM = "UPDATE eventDisplay SET " &_ "art_Title='" & fixQuotes( artTitle ) & "', " &_ "art_Category='" & fixQuotes( artCategory ) & "', " &_ "art_BDescription='" & fixQuotes( artBriefDesc ) & "', " &_ "art_Price='" & fixQuotes(artPrice ) & "', " &_ "art_ThumbFull='" & fixQuotes( Pimage ) & "', " &_ "art_Status='" & fixQuotes( artStatus ) & "', " &_ "art_Display=" & artDisplay & " " &_ " WHERE " &_ "cat_ID=" & catID end if ConnM.Execute strsqlM %>
Sorry its long



Reply With Quote
Bookmarks