2
Answers

File Uploading in asp.net

Smart    Lucky

Smart Lucky

13y
2.2k
1
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)