i'm doing a project in which i'm allowing user to upload image and the text related to that image..
once user gives text and browse image than clicks on save button the text and the image should be saved in directory(path of the image should be stored in database)...can anyone help me doing this in c# windows form application
Loading
pradeep nayakPosted Jul 26, 2012, 12:28 AM
Satyapriya NayakPosted Jul 25, 2012, 7:16 AM
Naresh AvariPosted Jul 25, 2012, 6:12 AM
According to your question, lets assume we have a button called btnUpload, TextBox called txtImgName and FileUpload control called fUpload.
and here is the code in button click:
protected void btnUpload_Click(object sender, EventArgs e)
{
if (fUpload.PostedFile.ContentType.StartsWith("image"))
{
string text = txtImgName.Text;
string imgName = fUpload.PostedFile.FileName.Substring(fUpload.PostedFile.FileName.LastIndexOf("\\") + 1);
fUpload.PostedFile.SaveAs(Server.MapPath("Categories\\" + imgName));
string Path = (Server.MapPath("Categories\\" + imgName));
}
}
Hope this helps...