Images upload to server

This code will help us to upload images to server.

on design page add a fileupload control and a button.

on button click:-


{
string fp;
fp = fileImgUpload.PostedFile.FileName ;
string fn;
fn = TextBox1.Text + "_" + TextBox2.Text + "_" + fp.Substring(fp.LastIndexOf("\\") + 1); // TextBox1 and TextBox2 is for image name(if we want to add some image name)
string sp;
sp = Server.MapPath("photo_contest");
if (sp.EndsWith("\\") == false)
{
sp += "\\";
}
sp += fn;
fileImgUpload.SaveAs(sp);
}


Comments

Author: rangasamy15 Oct 2009 Member Level: Bronze   Points : 0



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: