Sunday 15 May 2011

c# - Saving images from IP Camera to folder in application -



c# - Saving images from IP Camera to folder in application -

i have photographic camera connected network provides images can accessed ip. illustration this.

http://170.1.2.3/image?camera=2

i returned jpg file, can display on webpage using normal html.

<img src="http://170.1.2.3/image?camera=2" />

but instead of showing photographic camera image seen time of page load, want save image locally server using mvc4 application. in add-on nice include timestamp on filename. i'm not having luck finding illustration looks right me.

let's want start basic example:

string imgurl = "http://170.1.2.3/image?camera=2"; savelocally(imgurl, "newfilename-"+datetime.now.tostring());

.. , savelocally() should place file in "~/uploads". how do this? examples i've come across have been uploading file desktop. don't know how translate grabbing remote image.

update:

this incomplete answer, pointed out comments.

string url = "http://170.1.2.3/image?camera=2"; string localfilename = @"c:\projects\mvcapplication1\mvcapplication1\uploads\tofile.jpg"; using (webclient client = new webclient()) { client.downloadfile(url, localfilename); }

it works, don't fact file path absolute one. tried replacing localfilename ~/uploads/tofile.jpg results in error on execution. if possible want avoid having fixed location upload folder.

c# asp.net-mvc-4

No comments:

Post a Comment