我想当一个人作为我saite的成员时,当他登录以登录他/他的照片时,应该在页面顶部,在他/她的名字里面,我认为这个作品的名字是avatar? [英] i want when a person that she/he is a member of my saite , when he logined to saite her/his picture be on the top of pages,inside his/her name i think this works name is avatar?

查看:59
本文介绍了我想当一个人作为我saite的成员时,当他登录以登录他/他的照片时,应该在页面顶部,在他/她的名字里面,我认为这个作品的名字是avatar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望当一个人成为我的saite的成员时,当他登录以登录他/他的照片时,应该在页面顶部的他/她的名字之内
我认为此作品名称是头像?

i want when a person that she/he is a member of my saite , when he logined to saite her/his picture be on the top of pages,inside his/her name
i think this works name is avatar?

推荐答案

我使用asp.net,并设计了一个人向我的saite注册时上传的图片他/她和那张照片保存在我项目根目录下的一个文件夹中.该文件夹名为Uploads
那是一些代码
<< br模式="hold"/>字符串t = Request.MapPath(〜/Uploads");
Directory.CreateDirectory(t +"\\" + u.UserNam);
FileUpload1.SaveAs(t +"\\" + u.UserNam +"\\ profile.jpg");
>>
现在我想使用该图像,当那个人登录时
我知道我应该使用Cookies,但我不知道如何使用?"


首先,不要将它们存储在根目录中-而是将它们放在子文件夹中.两个原因:
1)如果这样做,则根文件夹将变得非常拥挤,这会使您在更新站点时识别要替换的文件变得更加困难-将它们保存在单独的文件夹中,然后您就知道它们都只是相关的给用户,而不是网站的机械".
2)所有人都需要访问根文件夹中的所有文件-是否已登录.这意味着我无需登录即可轻松获取站点上每个用户图片的副本...子文件夹可以具有不同的保护.

第二,为什么要使用Cookie?它们用于保存会话或页面之间的数据-而不用于显示图像!

显示图像并不困难.这里有一个提示可以做到这一点:一个通用ASP.NET的Image-From-DB类 [
"I use asp.net and I design that when a person register to my saite , upload a picture of him/her and that picture save on a folder in the root of my project.that folder name is Uploads
some of thats code
<<<br mode="hold" />String t = Request.MapPath("~/Uploads");
Directory.CreateDirectory(t +"\\"+ u.UserNam);
FileUpload1.SaveAs(t+ "\\"+ u.UserNam + "\\profile.jpg");
>>
and now i want to use this image, when that person login
i know i should use the Cookies but I dont know how?"


First off, don''t store them in the root - put them in a subfolder instead. Two reasons:
1) If you do then the root folder will get very crowded with images, which can make it a lot harder to identify which files to replace when you update the site - keep them in a separate folder and then you know they are all only related to the user, and not to the "mechanics" of your site.
2) All files in the root folder need to be accessible to everybody - logged in or not. Which means that I could easily snatch a copy of every user picture on your site without logging in... Sub folders can have different protection.

Second, why would you want to use cookies? They are for saving data between sessions, or pages - not for displaying images!

Displaying the image isn''t difficult. There is a Tip here that does just that: A generic Image-From-DB class for ASP.NET[^] It retrieves them from a DB, but a file is just as simple and only needs a small change!


这篇关于我想当一个人作为我saite的成员时,当他登录以登录他/他的照片时,应该在页面顶部,在他/她的名字里面,我认为这个作品的名字是avatar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆