using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Sample { public partial class Fileupload : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { cl1 cl = new cl1(); if (FileUpload1.HasFile) cl.check_save(); else { Label1.Text = "You have not specified a file"; } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using Sample; namespace Sample { public class cl1 : Fileupload { public void check_save() { int conlen = FileUpload1.PostedFile.ContentLength; if (conlen != null && conlen != 0) { if (FileUpload1.PostedFile.ContentLength > 400000) { Label1.Text = "Please select a low size file"; } else { try { FileUpload1.SaveAs("...................." + FileUpload1.FileName); Label1.Text = "Filename:" + FileUpload1.PostedFile.FileName + "<br>" + "Content type:" + FileUpload1.PostedFile.ContentType; } catch (Exception ex) { Label1.Text = "Error" + ex.Message.ToString(); } } } } } }
cl1
check_save()
Fileupload
Fileupload1
conlen != null
int
!= 0
conlen
FileUpload1.PostedFile.ContentLength
catch
ex.Message
string
ToString()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)