各位朋友,有在网页上上传视频,音频,图象文件等和在网页上播放视频,音频,FLASH动画的源代码吗(最好C#的,VB也行)? 大家帮帮忙!怎么样用C#编程,实现在网页上上传视频,音频,图象文件等和在网页上播放视频,音频,FLASH动画等或则希望大家能提供这方面的编程思想!先谢谢各位高手了!分不够再加! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个你看有用没有,写的比较匆忙,可能比较乱。(记得要在webconfig中添加 <httpRuntime maxRequestLength = "40000"/>,具体多少合适我没有测试),还有就是大文件上传有点问题。private Int32 UploadFile(HttpPostedFile postedFile,string strStoragePath) //new name path{ int BuffSize = 1024*4; Int32 i = postedFile.ContentLength; string FilePath = postedFile.FileName; if(FilePath == "" || FilePath == null) Response.End(); string FileName = FilePath.Substring(FilePath.LastIndexOf("\\")+1); try { Stream fClientStream; FileStream fWStream; fClientStream = (Stream)postedFile.InputStream; if(File.Exists(strStoragePath)==false) fWStream = new FileStream(strStoragePath,FileMode.Create);//不可覆盖 else return 0;//"Exist"; int iBlock =0; for(;iBlock<postedFile.ContentLength/BuffSize;iBlock++) { byte[] bBuff = new byte[BuffSize]; fClientStream.Read(bBuff,0, BuffSize); MemoryStream memStream = new MemoryStream(bBuff); memStream.WriteTo(fWStream); memStream.Close(); } byte[] bSubBuff = new byte[postedFile.ContentLength%BuffSize]; fClientStream.Read(bSubBuff,0, postedFile.ContentLength%BuffSize); MemoryStream SubStream = new MemoryStream(bSubBuff); SubStream.WriteTo(fWStream); SubStream.Close(); fWStream.Close(); fWStream = null; fClientStream.Close(); } catch(Exception ex){ return 0;}return i; } 播放视频,音频我一般都是调用mediaplay控件先定义一个变量:private string m_strAudioControl = @"<EMBED src='@FilePath@'; height='48' width = '300' type='audio/x-wav' loop='false' autostart='false' style=' POSITION: fixed; '/>";在确定文件路径的时候用路径替换掉@FilePath@,再赋值给一个label就可以了LbAudio.Text =m_strAudioControl.Replace("@AudioPath@",strVirtualPath); //strVirtualPath就是文件对应的虚拟路径下面是页面中的相应部分<asp:label id="LbAudio" runat="server"></asp:label> http://blog.csdn.net/hchxxzx/archive/2005/05/19/376362.aspx Flash就比较复杂一点,我也是在依葫芦画瓢,在看了播放flash的页面然后反推出来的,可能不太标准。设置7个string 类型的变量就是为了整齐点,呵呵private string m_strFlash1 = @"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab'' width='600' height='400' id=SOredirect align='middle' SWLIVECONNECT=true>'"; private string m_strFlash2 = @"<param name='allowScriptAccess' value='sameDomain' />"; private string m_strFlash3 = @"<param name='movie' value='@FlashPath@' />"; private string m_strFlash4 = @"<param name='quality' value='high' />"; private string m_strFlash5 = @"<param name='bgcolor' value='#FFFFFF' />"; private string m_strFlash6 = @"<embed src='@FlashPath@' quality='high' bgcolor='#FFFFFF' width='1' height='1' name='SOredirect' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' SWLIVECONNECT=true pluginspage='http://www.macromedia.com/go/getflashplayer' />";string strFlash = (m_strFlash1+m_strFlash2+m_strFlash3+m_strFlash4+m_strFlash5+m_strFlash6+m_strFlash7); LbFlash.Text =strFlash.Replace("@FlashPath@",strFlashVirtualPath); 大哥,这个还用.Net么?查查HTML的资料好了,有现成的ActiveX控件。 感谢朋友们相助!尤其是“ HuaGer(华戈) ”兄弟!结帖散分! 2个数据库里的数据转移的问题 既懂java又懂C#的来 如何写">\r\n \f\t\v带空格的字串\r\n \f\t\v<"这类字串的正则? C#控件实例 请问ContextMenuStrip中可以打对勾(也就是设置Check)的菜单项? 在线求助!!!!!急.... 21cn的邮件服务器是什么啊用MailMessage winForm 放入网页中可以吗? C#中,如果遍历TreeView中所有的节点? 请教一个list查询的问题 斑竹,请扶持下新人,谢谢!! 接触c#不久,感觉很郁闷,问个winform中datagrid的问题,希望高人解答
<httpRuntime maxRequestLength = "40000"/>,具体多少合适我没有测试),还有就是大文件上传有点问题。
private Int32 UploadFile(HttpPostedFile postedFile,string strStoragePath) //new name path
{
int BuffSize = 1024*4;
Int32 i = postedFile.ContentLength;
string FilePath = postedFile.FileName;
if(FilePath == "" || FilePath == null)
Response.End();
string FileName = FilePath.Substring(FilePath.LastIndexOf("\\")+1);
try
{
Stream fClientStream;
FileStream fWStream;
fClientStream = (Stream)postedFile.InputStream;
if(File.Exists(strStoragePath)==false)
fWStream = new FileStream(strStoragePath,FileMode.Create);//不可覆盖
else return 0;//"Exist";
int iBlock =0;
for(;iBlock<postedFile.ContentLength/BuffSize;iBlock++)
{
byte[] bBuff = new byte[BuffSize];
fClientStream.Read(bBuff,0, BuffSize);
MemoryStream memStream = new MemoryStream(bBuff);
memStream.WriteTo(fWStream);
memStream.Close();
}
byte[] bSubBuff = new byte[postedFile.ContentLength%BuffSize];
fClientStream.Read(bSubBuff,0, postedFile.ContentLength%BuffSize);
MemoryStream SubStream = new MemoryStream(bSubBuff);
SubStream.WriteTo(fWStream);
SubStream.Close();
fWStream.Close();
fWStream = null;
fClientStream.Close();
}
catch(Exception ex)
{
return 0;
}
return i;
}
先定义一个变量:
private string m_strAudioControl = @"<EMBED src='@FilePath@'; height='48' width = '300' type='audio/x-wav' loop='false' autostart='false' style=' POSITION: fixed; '/>";
在确定文件路径的时候用路径替换掉@FilePath@,再赋值给一个label就可以了
LbAudio.Text =m_strAudioControl.Replace("@AudioPath@",strVirtualPath);
//strVirtualPath就是文件对应的虚拟路径下面是页面中的相应部分
<asp:label id="LbAudio" runat="server"></asp:label>
private string m_strFlash1 = @"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab'' width='600' height='400' id=SOredirect align='middle' SWLIVECONNECT=true>'";
private string m_strFlash2 = @"<param name='allowScriptAccess' value='sameDomain' />";
private string m_strFlash3 = @"<param name='movie' value='@FlashPath@' />";
private string m_strFlash4 = @"<param name='quality' value='high' />";
private string m_strFlash5 = @"<param name='bgcolor' value='#FFFFFF' />";
private string m_strFlash6 = @"<embed src='@FlashPath@' quality='high' bgcolor='#FFFFFF' width='1' height='1' name='SOredirect' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' SWLIVECONNECT=true pluginspage='http://www.macromedia.com/go/getflashplayer' />";string strFlash = (m_strFlash1+m_strFlash2+m_strFlash3+m_strFlash4+m_strFlash5+m_strFlash6+m_strFlash7);
LbFlash.Text =strFlash.Replace("@FlashPath@",strFlashVirtualPath);
结帖散分!