开发者

How to upload/Save photo to a http server using webservice?

I have to upload photo to a folder in a HTTP server from a window application using web-service.I have converted the photo into stream and passed to a web-service but how can i save it to a location (eg: http:/siteaddress/i开发者_JS百科mages/photos/) in the server.


the web service has to get the stream from the client and convert it back to file in the location you mentioned.

string destinationFolder = Server.MapPath("/images/photos");

then assuming that in your web method you get a stream and a string with a unique file name, you save the steam into such file name in the destinationFolder above.

if you want to generate a unique name you can create a GUID, I'm sure you will need also the id of the user or so, just to save somewhere who has uploaded this photo.

the destination folder like images/photos should be taken from an app setting in the web.config or from the database, not hardcoded as in my example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜