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.

  1. creates folder in project path ~/uploads/images. here images concerned folder under uploads , uploads in root.

  2. while saving image path db use simple

    var dbpath= string.format("~/uploads/images/{0}",guid.newguid().tostring().replace("-",string.empty));

  3. and file upload control fu.saveas(server.mappath(dbpath));

if want display image on page database, either can use

  1. <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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -