在Web应用程序中通过网络摄像头保存和上传图像 [英] save and upload images through webcam in web application

查看:52
本文介绍了在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>解决方案

我也有这个问题,这个代码适用于localhost,但是当我发布应用程序时它不能工作...我尝试了很多并找到其他代码用于图像捕获,他们使用Jquery和javascript for webcam access ...它适用于我的应用程序。

下载文件来自http://dosya.co/1e5aaas1pzu3/WebCamApplication.rar.html

和integr吃了你的申请

祝你好运


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");

解决方案

I have also this problem,this code work fine for localhost but when I publish application it not working...I try lots and find other code for Image capture, they use Jquery and javascript for webcam access...It work fine with my application.
download file from http://dosya.co/1e5aaas1pzu3/WebCamApplication.rar.html
and integrate with your application
best luck


这篇关于在Web应用程序中通过网络摄像头保存和上传图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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