本文介绍了在Web应用程序中通过网络摄像头保存和上传图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在网络应用程序中通过网络摄像头保存和上传图像。请帮助。我试过这个代码,在本地机器上工作但是在托管之后,它没有在服务器上保存图像:
System.Drawing.Image originalimg;
string strFile = DateTime.Now.ToString(dd_MMM_yymmss)+.jpg;
FileStream log = new FileStream(Server.MapPath(strFile),FileMode.OpenOrCreate);
byte [] buffer = new byte [1024] ;
int c;
while((c = Request.InputStream.Read(buffer,0,buffer.Length))> 0)
{
log.Write(buffer,0,c);
}
originalimg = System.Drawing.Image.FromStream(log );
originalimg = originalimg.GetThumbnailImage(320,240,new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback),IntPtr.Zero);
来源alimg.Save(Server.MapPath(Images)+\\+ strFile);
// @originalimg.Save(D:\\WebcamImages \\ + strFile);
//写jpg文件名,由正则表达式拾取并显示在flash html页面上。
log.Close();
originalimg.Dispose();
File.Delete(Server.MapPath(strFile));
Response.Write(../ Images /+ strFile) ; $ / b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ h2_lin>解决方案
How to save and upload images through webcam in web application.Please help.I hv tried this code,working on local machine but after hosting,its not saving the image at server:
System.Drawing.Image originalimg;
string strFile = DateTime.Now.ToString("dd_MMM_yymmss") + ".jpg";
FileStream log = new FileStream(Server.MapPath(strFile), FileMode.OpenOrCreate);
byte[] buffer = new byte[1024];
int c;
while ((c = Request.InputStream.Read(buffer, 0, buffer.Length)) > 0)
{
log.Write(buffer, 0, c);
}
originalimg = System.Drawing.Image.FromStream(log);
originalimg = originalimg.GetThumbnailImage(320, 240, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
originalimg.Save(Server.MapPath("Images") + "\\" + strFile);
//originalimg.Save( "D:\\WebcamImages\\" + strFile);
//Write jpg filename to be picked up by regex and displayed on flash html page.
log.Close();
originalimg.Dispose();
File.Delete(Server.MapPath(strFile));
Response.Write("../Images/" + strFile);
Session["ImgUrl"] = "../Images/" + strFile;
Response.Redirect("PhotoCapture.aspx");
解决方案
这篇关于在Web应用程序中通过网络摄像头保存和上传图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!