如果用户没有上传他的profilepic,如何上传默认配置文件pic [英] How to upload default profile pic if user not uploaded his profilepic

查看:90
本文介绍了如果用户没有上传他的profilepic,如何上传默认配置文件pic的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到上传我已经完成的个人资料照片,但是当用户没有上传他的个人资料时,我在上传默认个人资料照片时遇到问题。



//以下是我上传个人资料的代码图片

<前一个=c#> 如果(UploadPhoto.HasFile)
{
string UploadFolderPath = Profile_Pic \\ + txtChildName.Text + _;
UploadFolderPath = UploadFolderPath + UploadPhoto.FileName;
UploadPhoto.SaveAs(Server.MapPath(UploadFolderPath));

if (UploadFolderPath.ToLower()。EndsWith( 。jpg))
{
cmdAdmission.Parameters.Add( new SqlParameter( @ Photo_Path,SqlDbType.NVarChar, 200 ));

cmdAdmission.Parameters [ @ Photo_Path]。Value = UploadFolderPath;
}
}
else
{
// 这里我必须采取默认的配置文件图片
}

解决方案

else

{



string defaultpic =shadowimage.jpg;



sqlcomm.Parameters.Add(@ profilepic,SqlDbType.VarChar,200).Value = defaultpic;



}

在Profilepic文件夹中添加此shadowimage.jpg然后



欢迎页面Image1.ImageUrl =Profilepic \\+ dr [pic]。如果用户没有上传他的照片,ToString()

显示该照片。


Up to uploading the profile pic i have completed but i am facing problem in uploading default profile pic when the user not uploaded his profile pic

//below is my code for upload profile pic

if (UploadPhoto.HasFile)
{
string UploadFolderPath = "Profile_Pic\\" + txtChildName.Text + "_";
UploadFolderPath = UploadFolderPath + UploadPhoto.FileName;
UploadPhoto.SaveAs(Server.MapPath(UploadFolderPath));

if (UploadFolderPath.ToLower().EndsWith(".jpg"))
{
cmdAdmission.Parameters.Add(new SqlParameter("@Photo_Path", SqlDbType.NVarChar,200));

cmdAdmission.Parameters["@Photo_Path"].Value = UploadFolderPath;
}
}
else
{
//here i have to take default Profile Pic
}

解决方案

else
{

string defaultpic="shadowimage.jpg";

sqlcomm.Parameters.Add("@profilepic", SqlDbType.VarChar, 200).Value = defaultpic;

}
In Profilepic folder add this shadowimage.jpg then

on welcome page Image1.ImageUrl="Profilepic\\"+dr["pic"].ToString()
show that pic if user did not upload his pic.


这篇关于如果用户没有上传他的profilepic,如何上传默认配置文件pic的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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