Smart    Lucky

Smart Lucky

  • NA
  • 555
  • 640.9k

File Uploading in asp.net

Mar 28 2011 4:22 AM
Aslam-0-Alaikum

   if (FileUpload1.PostedFile != null)
        {
            if (FileUpload1.PostedFile.ContentType == "jpg" || FileUpload1.PostedFile.ContentType == "gif" || FileUpload1.PostedFile.ContentType == "png")
            {
                if (FileUpload1.PostedFile.ContentLength == 20)
                {
                    string fileName = FileUpload1.FileName;
                    FileUpload1.SaveAs(@"D:\" + fileName);
                    Response.Write("File Uploaded");
                }
                else
                {
                    Response.Write("Image must 20 kb");
                }
            }
            else
            {
                Response.Write("File must be Image");
            }
        }
        else Response.Write("Please select file to upload");


it is not working idon't know but why ..............?

And

   FileUpload1.PostedFile.SaveAs(Server.MapPath("~/App_Data") + System.IO.Path.DirectorySeparatorChar + FileUpload1.PostedFile.FileName);

    ystem.IO.Path.DirectorySeparatorChar   What is mean this ....?














Answers (2)