upload the image and display it

Author Topic
devon philip
Member

Joined: 25 Nov 2008
Country: USA
Posts: 1

Posted: 25 Nov 2008 11:12:11

hi all,

I want to upload the image in on folder and than display it onto page.

I use this code for upload the image



public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
string ImagesFolder = "MatchImages";
string savePath;
string saveFile;
if (FileUpload1.HasFile)
{
try
{
// perform the upload
//www.infysolutions.com
savePath = Path.Combine(Request.PhysicalApplicationPath,
ImagesFolder);
saveFile = Path.Combine(savePath, FileUpload1.FileName);
FileUpload1.SaveAs(saveFile);
// Displays status of success
FileUploadReport.Text = "Your file was uploaded successfully.";
}
catch(Exception exUpload)
{
// display status of error
FileUploadReport.Text = exUpload.Message;
}
}
else // probably file was not selected
{
// Display status of failure
FileUploadReport.Text = "You did not specify a file to upload.";
}
}
----------------------------------------------------------------------------------------------
Software development company

hi all,

I want to upload the image in on folder and than display it onto page.

I use this code for upload the image



public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
string ImagesFolder = "MatchImages";
string savePath;
string saveFile;
if (FileUpload1.HasFile)
{
try
{
// perform the upload
//www.infysolutions.com
savePath = Path.Combine(Request.PhysicalApplicationPath,
ImagesFolder);
saveFile = Path.Combine(savePath, FileUpload1.FileName);
FileUpload1.SaveAs(saveFile);
// Displays status of success
FileUploadReport.Text = "Your file was uploaded successfully.";
}
catch(Exception exUpload)
{
// display status of error
FileUploadReport.Text = exUpload.Message;
}
}
else // probably file was not selected
{
// Display status of failure
FileUploadReport.Text = "You did not specify a file to upload.";
}
}
----------------------------------------------------------------------------------------------
Software development company
Follow us on twitter Subscribe to our RSS feed
Activate your free membership today | Login | Currency