从数据库保存和检索图像 [英] save and retrieve image from database
本文介绍了从数据库保存和检索图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi ..
我有一个页面,在该页面上我正在使用文件上载控件来保存图像,而在另一个页面上,我想检索图像.
为了保存数据,我使用了代码
hi..
I have a page on which i am using file upload control to save image and on another page i want to retrieve the image.
to save data i used the code
if (FileUpload1.HasFile)
{
try
{
bool isValidType = false;
string filename = FileUpload1.PostedFile.FileName;
string[] validext = { "pdf", "doc", "docx"};
string ext = System.IO.Path.GetExtension(FileUpload1.FileName);
for (int i = 0; i < validext.Length; i++)
{
if (ext == "." + validext[i])
{
isValidType = true;
break;
}
}
if (!isValidType)
{
lblmessage.Text = "pdf, doc, docx Files are allowed";
}
else
{
FileUpload1.SaveAs(Server.MapPath("~/Resume") + filename);
_zeumay.cv_uploaded_url = "~/Resume/" + filename;//Path Of the Uploaded Cv
}
}
这有什么错误吗??
还告诉我如何在其他页面的图像控件中检索图像.
[edit]添加了代码块并更正了索引[/edit]
Is there any mistake in this.?
and also ell me how to retrieve image in image control in other page.?
[edit]code block added and indexation corrected[/edit]
推荐答案
HI使用Server.Mappath
试试这个
_zeumay.cv_uploaded_url = Server.Mappath(〜")+"/Resume/" +文件名;//上传的Cv的路径
HI use Server.Mappath
Try This
_zeumay.cv_uploaded_url =Server.Mappath("~")+"/Resume/" + filename;//Path Of the Uploaded Cv
这篇关于从数据库保存和检索图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文