if (FileUpload1.HasFile) { string imagename = System.IO.Path.GetFileName(FileUpload1.FileName); string ext = System.IO.Path.GetExtension(FileUpload1.FileName); string imagefile = Server.MapPath("Pictures/" + imagename + ext); byte[] Image = null; if (ext == ".jpg" | ext == ".gif" | ext == ".png") { Image = new byte[FileUpload1.PostedFile.ContentLength]; HttpPostedFile UploadedImage = FileUpload1.PostedFile; UploadedImage.InputStream.Read(Image, 0, (int)FileUpload1.PostedFile.ContentLength); int numBytesToRead = Image.Length; try { using (FileStream fsNew = new FileStream(imagefile, FileMode.Create, FileAccess.Write)) { fsNew.Write(Image, 0, numBytesToRead); } } catch (FileNotFoundException ioEx) { Label100.Text = "Filestream Add Pictures: " + ioEx.ToString(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)