Click here to Skip to main content
15,918,889 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Respected sir,
I am ashish and i want to code for uploading to and download videos/audios/mp3 file from our website using asp.net how it can be done please help me my email id is [REMOVED]@yahoo.in
thankingyou
Posted
Updated 3-Sep-11 3:27am
v2
Comments
Wendelius 3-Sep-11 9:28am    
email address removed. Never include your address in a post unless you want excessive amounts of spam. The possibly solutions that are added to this question are automatically posted to you to your account's email address.

For uploading you can use the File Upload Control.
Here[^] is an introduction to it.

You can read a little about downloading files here[^].
 
Share this answer
 
Comments
Uday P.Singh 3-Sep-11 13:45pm    
nice links especially first one, my 5!
Use FileUpload control and
try this code on buuton click
C#
protected void btnSub_Click(object sender, EventArgs e)
{
    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);

        path = "~\\Uploads4\\" + filename;
        SqlConnection con = new SqlConnection(str);
        lblinfo.Text = " uploaded successfully ";
        cmd = new SqlCommand("Insert into tablename(Video_Name,url) values(@Video,'" + path + "')", con);
        cmd.Parameters.AddWithValue("Video", TextBox2.Text);
        cmd.CommandType = CommandType.Text;
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
    }
 
Share this answer
 
Comments
Abhinav S 3-Sep-11 13:50pm    
Good link if OP wants to save to database.
 
Share this answer
 
Comments
Abhinav S 3-Sep-11 13:50pm    
Good links. 5.
RaviRanjanKr 3-Sep-11 14:14pm    
Nice link, My 5+
In addition to above answer of Abhinav and Uday. I will also suggest you to navigate given links ASP.NET 2.0 FileUpload Server Control[^] and have go through the whole series of article to learn how to use Upload Control.
 
Share this answer
 
Well, not exact solution for this problem, But after uploading you may find some problem short of this with IIS.
I got this error when i use Itestsharp?[^]
Just answered this question so thought to share with you.
 
Share this answer
 

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