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

mekrem

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 called \[code\]covers\[/code\] which has a column called \[code\]img\[/code\] with data type \[code\]image\[/code\].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 \[code\]database.asp\[/code\]. The connection is working because all the columns like \[code\]c_name\[/code\], \[code\]category\[/code\], \[code\]date_upl\[/code\] are getting updated in the database table \[code\]covers\[/code\] except for the \[code\]img\[/code\] column.It's not taking up the image path. Is \[code\]rs("img") = request.Form("browse_file")\[/code\] a wrong asp recordset to update database column?
 
Back
Top