I have hosted my website on godaddy.com. THey have a limitation on the size of db. So i cannot load all the photos i have into the db. I wanted to store the photo into the file system and store the path into the database. At this point I still m not sure
why were photos required to be stored into the db. as this has some catastrophic performance issus on my website. I am lookig for some samples to see if somebody has already changed the code to store the name of he tfile rather tha the image bytes itself.
jankajg
Member
43 Points
24 Posts
store images to file system instead of db
Feb 24, 2009 04:47 AM|LINK
hello,
I have hosted my website on godaddy.com. THey have a limitation on the size of db. So i cannot load all the photos i have into the db. I wanted to store the photo into the file system and store the path into the database. At this point I still m not sure why were photos required to be stored into the db. as this has some catastrophic performance issus on my website. I am lookig for some samples to see if somebody has already changed the code to store the name of he tfile rather tha the image bytes itself.
Many thanks in Advance,
Janak
.Net Development
sarang2511
Member
125 Points
34 Posts
Re: store images to file system instead of db
Feb 24, 2009 06:39 AM|LINK
Hi Janak
I have done what you are asking for.
you need a file upload control and this uploadcatimage will return the path where the image is.
private string UploadCatImage()
{
string filepath = string.Empty;
string savepath = string.Empty;
string virtualfolder = string.Empty;
filepath = Server.MapPath("./") + "Category";
if (FileUpload1.PostedFile.ContentLength != 0)
{
string filename = string.Empty;
string str = tbuname.Text.ToString();
filename = str + "." + GetExtension(FileUpload1.PostedFile.FileName);;
savepath = "Category/" + filename;
FileUpload1.PostedFile.SaveAs(filepath + "/" + filename);
return savepath;
}
else
{
savepath = "Category/blankimg.jpeg";
return savepath;
}
}
private string GetExtension(string FileName)
{
string[] split = FileName.Split('.');
string Extension = split[split.Length - 1];
return Extension;
}
||Mark as answer if it's of any help to you||
My Forum