asp.net2.0 upload file
use FileUpload control. this example checks for file type, empty file
protected void btnSaveFile_Click(object sender, EventArgs e)
{
if (IsPostBack)
{
Boolean fileOK = false;
String path = @"C:\temp\";
if (FileUpload1.HasFile)
{
String fileExtension =
System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
String[] allowedExtensions =
{ ".gif", ".png", ".jpeg", ".jpg" };
for (int i = 0; i < fileextension ="="" fileok =" true;" text = "File uploaded!" text = "File could not be uploaded." text = "Cannot accept files of this type.">
reference: http://msdn2.microsoft.com/en-us/library/ms227669.aspx
No comments:
Post a Comment