master.fake
master.fake

Reputation: 487

Uploading MP3/Video File

In my C# Project I tried to include media files. But when I tried to use the upload/download code that I successfully used for the image and document, did not went right. So can anyone help me out with the upload and download of the audio and video files.

My code: For upload:

if (musicFile.HasFile)
{
    musicFile.SaveAs(Server.MapPath(type) + "/" + musicFile.FileName);
    musicfile = musicFile.FileName;
}

For download:

Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
Response.TransmitFile(Server.MapPath("MP3/") + filename);
Response.End();

Please I need it fast...

Upvotes: 0

Views: 1552

Answers (1)

Mehrdad
Mehrdad

Reputation: 2116

Code for upload is correct but 2 points: 1. Make sure the address is right (type string) 2. You should set access for the folder you would uploading on the host

And for download you could easily provide a link pointing to your file: < a href="~/Music/MyFile.mp3">My Mp3< /a>

Upvotes: 2

Related Questions