使用C#.net中的Fileupload Conntrol保存视频文件 [英] Save a Video File using Fileupload Conntrol in C#.net

查看:99
本文介绍了使用C#.net中的Fileupload Conntrol保存视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是朋友.我制作了一个Web应用程序,我想在其中上传视频文件并将其保存在特定的文件夹中.但是,当我单击按钮时,我给出了一个错误,单击按钮给出错误后,Button_Click事件不触发.但是,当我上传图片时,效果很好.所以你能告诉我何浩来解决这个问题.

请帮助我

谢谢与问候

Parveen Rathi

Hi.. Friends, I making a web application in which I want to upload video file and want to save in a specific folder. But when I click on button then I gives an error the Button_Click event not fires after click it give a error. But when I upload an image it works well. So will u tell me please Ho to resolve this problem.

Please help me

Thanks & Regards

Parveen Rathi

推荐答案

try
        {
            UploadVideo obj = new UploadVideo();
            string filename = fuUploadVideo.FileName;
            string path = Server.MapPath("Uploads4");
            string strFinalFileName = Path.GetFileName(fuUploadVideo.FileName);
            long FileLength = fuUploadVideo.PostedFile.ContentLength;
            long uploadchunklimit;
            int SizeLimit = (int)FileLength;
            if (FileLength <= 1024)
            {
                uploadchunklimit = 1;
                SizeLimit = (int)FileLength;
            }
            else if (FileLength > 1024)
            {
                uploadchunklimit = FileLength / 1024;
                SizeLimit = 10;
            }
            else if (FileLength <= 10240 && FileLength > 1024)
            {
                uploadchunklimit = FileLength / 1024;
            }
            else
            {
                uploadchunklimit = FileLength / 1024;
            }

            long lngSize = (long)SizeLimit;
            lngSize = 1024 * 1024;
            string ext = Path.GetExtension(fuUploadVideo.PostedFile.FileName);
            
            fuUploadVideo.PostedFile.SaveAs(Server.MapPath("Uploads4\\" + filename));
            path = "Uploads4\\" + filename;
            SqlConnection con = new SqlConnection(str);
           
            cmd = new SqlCommand("Insert into electronicmedia(Video_Name,url) values(@Video,'" + path + "')", con);
            cmd.Parameters.AddWithValue("Video", TextBox2.Text);
            cmd.CommandType = CommandType.Text;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            lblinfo.Text = " uploaded successfully ";
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }


文件很大,请转到您的webconfig文件&增加

< system.web>
< httpRuntime maxRequestLength ="11296"/>
</system.web>
the file size is huge go to your webconfig file & increase

<system.web>
<httpRuntime maxRequestLength="11296"/>
</system.web>


这篇关于使用C#.net中的Fileupload Conntrol保存视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆