Hi,
I want to save images in a default directory , can be project setup directory.
Thanks in Advance,
A.Durga Prasad
Saving Images in a Default directory
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Kaustubh Mhadgut4 pointsPosted Jan 22, 2009, 12:57 AM EST
Hi,
Use the FileUpload control.
<asp:FileUpload runat="server" id="FileUpload1" />
Then on a button click.
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/image/") + "filenamewith extension"
You can specify whatever path you want.
durga prasad29 pointsPosted Jan 26, 2009, 9:25 PM EST
I was asking this one for Windows Application and not for web application,anyhow I got the answer , for others who may be intrested can see this.
Adding Image
string image_outputDir = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
DirectoryInfo df = new DirectoryInfo(image_outputDir + @"\images\" + dbfTxtImageName.Text);
dbfTxtImageURL.Text = df.ToString();
Saving the image in application directory
string image_outputDir = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
DirectoryInfo df = new DirectoryInfo(image_outputDir + @"\images\" + dbfTxtImageName.Text);
String paths;
paths = df.ToString();
txtimages.Image.Save(paths,System.Drawing.Imaging.ImageFormat.Jpeg);
MessageBox.Show("Image Saved succesfully");
Displaying the image, after saving the image url in the database
txtimages.Image =Image.FromFile(Path,true);