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 ....?


Krishna GaradRank #191 · 12.8K reputationPosted Mar 28, 2011, 12:56 AM EDT
string virtualFolder = "~/Upload/";
string physicalFolder = Server.MapPath(virtualFolder);
FileUpload1.SaveAs(physicalFolder + FileUpload1.FileName);
it will work for that create Upload folder in root directory. The server.MapPath will map the path on server for specified location.
Suthish NairRank #92 · 22.8K reputationPosted Mar 28, 2011, 3:06 AM EDT