动态图像从PC上传到网站 [英] Dynamic Image upload from PC to Website

查看:98
本文介绍了动态图像从PC上传到网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在ASP.NET MVC 5中开发Web应用程序,其中一个想要在其上显示图像的Web。该Web表单应该像dropbox一样工作(如果我将图像放入我的PC文件夹,它可能会自动与我的网站合成)。我只是缺乏做这种事情。任何人请提出一个想法。

I'm Developing web application in ASP.NET MVC 5, One of the web from wants to show an images on it. That web form should work as like dropbox (If i put a image into my PC folder, it may automatically synthesize with my website). i'm just getting lack to do this type of thing. Any one please give an ideas.

推荐答案

你需要的是别的东西。它不是您网站的普通客户端,而是一个功能齐全的应用程序软件,可以管理您的文件系统,同时在服务器上记录您的文档和文件。



Dropbox应用程序在您的文件系统上创建一个要管理的文件夹。监视器会监视其中的所有文件。在实际中,(或在.NET中),您可以使用 FileSystemWatcher [ ^ ]确定何时在该目录中发生更改的对象。 我建议您阅读有关该课程的评论



您的应用程序需要此对象,以便跟踪该目录或其中的文件发生的情况。然后,您可以执行不同的操作。例如,如果将新文件添加到文件夹,您可以将该文件传递到您的网站(或云?)。 HttpClient [ ^ ]将是一个非常完美的候选人(恕我直言)。



What you need is something else. It is not an ordinary client for your website, instead it is a full featured application software that manages your file system and at the same time keeps a note of your documents and files on the server.

Dropbox application creates a folder on your file system to manage. All of the files in it are watched by a watchdog. In real, (or in .NET) you can use a FileSystemWatcher[^] object to determine when a change occurs in that directory. I recommend that you read the remarks about the class.

Your application needs this object in order to keep a track of what happens to that directory or the files in it. Then you can perform different actions. For example if a new file is added to the folder, you can pass that file to your website (or cloud?). HttpClient[^] would be a very perfect candidate (IMHO).

using (var client = new HttpClient()) {
   // get the location of that file
   // POST a multipart/form-data content
}





可以在此主题中找到示例: http://stackoverflow.com/questions/18059588/httpclient-multipart-form-post- in-c-sharp [ ^ ]



最后,您需要处理请求并捕获内容并上传。一个很长的,但是...我相信如果你只是先将算法放在纸上,然后逐步编写源代码,你就可以完成它。



A sample for that can be found in this thread: http://stackoverflow.com/questions/18059588/httpclient-multipart-form-post-in-c-sharp[^]

Then finally, you need to handle the request and capture the content and upload it. A long one, but... I am sure if you simply put the algorithm on paper first and then write the source code step-by-step you will be able to get it done.


这篇关于动态图像从PC上传到网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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