Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
[no name] 22-Dec-11 1:03am    
What is the error? If you want help you must give complete information. Edit your question to provide further details.
Karthik Harve 22-Dec-11 1:04am    
are you using Combination of FileUpload and Button Controls..???
Karthik Harve 22-Dec-11 1:04am    
show some code..!!

C#
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());
        }
 
Share this answer
 
Comments
Parveen Rathi 22-Dec-11 1:42am    
UploadVideo obj = new UploadVideo();

Sir what is UploadVideo here
uspatel 24-Dec-11 5:44am    
Sorry, Ignore this.Actually it is a class created by me for some purpose.
the file size is huge go to your webconfig file & increase

<system.web>
<httpRuntime maxRequestLength="11296"/>
</system.web>
 
Share this answer
 
Comments
Parveen Rathi 22-Dec-11 2:08am    
Thank you so much Sir
Mehtab74 14-Nov-12 12:29pm    
Thanks for this.It is very useful....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900