关于asp.net [英] regarding the asp.net

查看:54
本文介绍了关于asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生,
我很灰心,我想编码使用asp.net从我们的网站上载和下载视频/音频/mp3文件,该怎么办? Thankingyou

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

推荐答案

要进行上传,可以使用文件上传控件.
此处 [此处阅读一些有关下载文件的信息. [ ^ ].
For uploading you can use the File Upload Control.
Here[^] is an introduction to it.

You can read a little about downloading files here[^].


使用FileUpload控件和
在buuton上尝试此代码,请点击
Use FileUpload control and
try this code on buuton click
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();
    }


检查以下内容:

对于FileUpload:

ASP.NET 2.0 FileUpload服务器控件 [在ASP.NET中下载文件并跟踪下载成功/失败的状态 [
check these out:

For FileUpload :

ASP.NET 2.0 FileUpload Server Control[^]

For File Download:

File Download in ASP.NET and Tracking the Status of Success/Failure of Download[^]

hope it helps :)


这篇关于关于asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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