Net audio file upload and playback code

Source: Internet
Author: User
Tags file upload


public static string Getflashtext (string url)
{
String str = @ "<object id= ' MediaPlayer ' classid= ' clsid:6bf52a52-394a-11d3-b153-00c04f79faa6 ' height= '" width= ' 406 ' >
<param name= ' rate ' value= ' 1 '/>
<param name= ' balance ' value= ' 0 '/>
<param name= ' currentposition ' value= ' 0 '/>
<param name= ' defaultframe ' value= '/>
<param name= ' playcount ' value= ' 1 '/>
<param name= ' AutoStart ' value= '-1 '/>
<param name= ' currentmarker ' value= ' 0 '/>
<param name= ' invokeurls ' value= '-1 '/>
<param name= ' baseurl ' value= '/>
<param name= ' volume ' value= ' 2 '/>
<param name= ' mute ' value= ' 0 '/>
<param name= ' uimode ' value= ' full '/>
<param name= ' stretchtofit ' value= ' 0 '/>
<param name= ' windowlessvideo ' value= ' 0 '/>
<param name= ' enabled ' value= '-1 '/>
<param name= ' enablecontextmenu ' value= ' 0 '/>
<param name= ' fullscreen ' value= ' 0 '/>
<param name= ' samistyle ' value= '/>
<param name= ' Samilang ' value= '/>
<param name= ' samifilename ' value= '/>
<param name= ' captioningid ' value= '/>
<param name= ' enableerrordialogs ' value= ' 0 '/>
<param name= ' _cx ' value= ' 10742 '/>
<param name= ' _cy ' value= ' 1799 '/>
<param name= ' URL ' value= ' +url+ '/></object> ';
return str;
}


protected void Button1_Click (object sender, EventArgs e)
{
foreach (uploadedfile file in RadUploadContext.Current.UploadedFiles)
{
if (file. FileName!= null && file. FileName!= "")
{
String strtime = MemberID. ToString () + "-" + DateTime.Now.Year.ToString () + DateTime.Now.Month.ToString () + DateTime.Now.Day.ToString () + DateTime . Now.Hour.ToString () + DateTime.Now.Minute.ToString () + DateTime.Now.Millisecond.ToString ();
String namefile = file. filename;//get the original name of the file
String namelast = NameFile. Substring (NameFile. LastIndexOf (".")); /get the suffix name of the file, LastIndexOf ()-Returns the position of the character in parentheses
String FilePath = System.AppDomain.CurrentDomain.BaseDirectory + @ "savefilepath/mbmusic/";//File Upload path
System.IO.FileInfo fi = new System.IO.FileInfo (file. FileName);
if (FI. Extension.tolower () = = ". mp3" | | Fi. Extension.tolower () = = ". wma" | | Fi. Extension.tolower () = = ". Rm" | | Fi. Extension.tolower () = = ". wav")
{
String name = Strtime + namelast;//file Last saved name
MV = "http://www.cnblogs.com/SaveFilePath/MBmusic/" + name;
filesizes = Int. Parse (file. Contentlength.tostring ());
String path = FilePath + name;
if (file.exists (path) = = False)
{
File. SaveAs (FilePath + name);
Mf. Mf_path = MV;
Mf. Mf_path = MV;
}
else if (file.exists (path) = = True)
{
Name = Strtime + "(" + TT + ")" + namelast;
File. SaveAs (FilePath + name);
MV = "http://www.cnblogs.com/SaveFilePath/MBmusic/" + name;
Mf. Mf_path = MV;
Mf. Mf_path = MV;
}
if (remainbytesize >= filesizes)
{
Try
{
Inserting data into a database tutorial
if (Addnum > 0 && UDPS Tutorial ize > 0)
{
Response.Write (' Upload success!! ') ("<script>alert") </script> ");
Bind ();
}
Else
{
Response.Write ("<script>alert" (' Upload failed!! ') </script> ");
Return
}
num++;
}
Catch {}
}
Else
{
Response.Write ("<script>alert (' space is not enough, please apply for space!! ') </script> ");
Return
}
}
Else
{
Response.Write (' <script>alert (' upload file format is wrong! File format for MP3,WMA,WAV.RM video! ') </script> ");
Return
}
}
Else
{
Response.Write ("<script>alert (' Please select uploaded file ') </script>");
Return
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.