How do I store image path in SQL database using Classic ASP.?

Trev

New Member
I'm uploading a image file, for that I have used \[code\]<input type="file" name="browse_file" accept="image/*"/>\[/code\] in my form .I have a table named "covers" which has a field called "img" with data type as "image".This is what my html looks likeHTML\[code\]<table border="1" cellpadding="5" cellspacing="0" width="100%"> <tr> <td width="20%"><b>Choose Cover:</b></td> <td> <input type="file" name="browse_file" accept="image/*"/> <% session("file_name") = request.Form("browse_file") %> </td> </tr> <tr> <td><strong>Cover Name:</strong></td> <td><input type="text" name="cover_name" value=""></td> </tr> <tr> <td><strong>Choose Category:</strong></td> <td> <select name="disp_cat" onchange="return refresh_cat();"> <option selected="selected" value="http://stackoverflow.com/questions/12419828/0">Choose Category...</option> <% sql = "SELECT * from categories" rs.open sql, con, 1, 2 do while not rs.eof %> <% if rs("name") = request.Form("disp_cat") then%> <option value="http://stackoverflow.com/questions/12419828/<%=rs("name")%>" selected="selected"><%=rs("name")%></option> <%else%> <option value="http://stackoverflow.com/questions/12419828/<%=rs("name")%>"><%=rs("name")%></option> <%end if rs.movenext loop rs.close %> </select> </td> </tr> <tr> <td colspan="2"> <input type="submit" value="http://stackoverflow.com/questions/12419828/Save" name="save_cover" onclick="return show_alert2();"/> <input type="submit" value="http://stackoverflow.com/questions/12419828/Cancel" name="cancel" onclick="return go_back();"/> </td> </tr> <% if request.Form("save_cover") <> "" then sql = "SELECT * from covers" rs.open sql, con, 1, 2 rs.addnew rs("c_name") = request.Form("cover_name") rs("category") = request.Form("disp_cat") rs("img") = request.Form("browse_file") rs("date_upl") = date() rs.update response.Write("<script language='javascript'>{update1();}</script>") rs.close end if %> </table>\[/code\]Connection to database is defined in a separate file called database.asp . The connection is working because all the fields like c_name , category, date_upl are getting updated in the database table covers except for the img field .Its not taking up the image path. Is \[code\]rs("img") = request.Form("browse_file")\[/code\] a wrong asp recordset to update database field..??
 
Back
Top