c# - File management for profile pictures -
i'm bulding asp.net website users can upload profile picture. store these images under app_data folder , file paths in users table.
so, question how should update user's profile picture? mean, happens if overwrite previous file , @ same time request arrives picture. should have concurrency management? best solution generating file name new image(the user record in database updated new path well) , store old path somewhere else, in order delete later. idea?
what in case.
creates folder in project path ~/uploads/images. here images concerned folder under uploads , uploads in root.
while saving image path db use simple
var dbpath= string.format("~/uploads/images/{0}",guid.newguid().tostring().replace("-",string.empty));
and file upload control
fu.saveas(server.mappath(dbpath));
if want display image on page database, either can use
<asp:image runat="server" id="immm"></asp:image> , code behind imm.imageurl = dt.rows[0]["imagepath"].tostring"
2.if inside grid/repeater, use <asp:image runat="server" id="immm" imageurl='<%#eval("imagepath")%'></asp:image>
Comments
Post a Comment