private void UploadVideo()
{
if (FileUpload1.HasFile == true)
{
string ext = Path.GetExtension(FileUpload1.FileName).ToLower();
string[] allowedtypes = new string[] { ".flv" };
if (allowedtypes.Contains(ext))
{
string[] mimetypes = new string[] { "application/x-shockwave-flash", "application/octet-stream", "video/x-flv" };
string filetype = FileUpload1.PostedFile.ContentType;
if (mimetypes.Contains(filetype) == false)
{
// error = "Image is not in the correct format, Please ensure the image is either a JPEG, GIF or PNG";
return;
}
else
{
string filename = Session["StudentID"].ToString() +"_"+ DateTime.Now + ext.ToString();
filename = filename.Replace("/", "").Trim();
filename = filename.Replace(":", "");
filename = filename.Replace(" ", "");
string strpath = "Video/" + filename;
FileUpload1.SaveAs(Server.MapPath("~/forum/Video/") + filename);
}
}
else
{
lblMassage.Text = "Only .FLV format supported";
return;
}
}
else
{
lblMassage.Text = "No file selected.";
return;
}
}
No comments:
Post a Comment