[英]File upload in Visual WebGUI
So I'm tasked to build a file upload for our application, which is using Visual WebGUI and therefore mostly looks like WinForms codewise. 因此,我受命为使用Visual WebGUI的应用程序构建文件上载,因此通常看起来像WinForms。
The problem is, I don't have any clues as to where to start. 问题是,我不知道从哪里开始。 I tried looking through our Download class, but it just takes a file and puts it into the response.
我尝试浏览我们的Download类,但它只需要一个文件并将其放入响应中。
I tried google, but there's nothing on uploading something. 我尝试了google,但是没有上传任何内容。
I don't understand enough of how websites work to even ask myself or google the right question. 我对网站的工作方式了解甚少,甚至无法问自己或Google正确的问题。 I have no Idea how a website tells the browser to get a file.
我不知道网站如何告诉浏览器获取文件。 And if I find out how that works, I still need to somehow get VWG to do that.
而且,如果我知道它是如何工作的,我仍然需要以某种方式让VWG来做到这一点。 I can't directly interact with the browser (except when I write javascript, but I'm not sure I can get a response from js).
我无法直接与浏览器进行交互(除非编写JavaScript,但我不确定我是否可以从js获得响应)。
Ideas and clues to where to start would be great too, I just need somewhere to start. 从哪里开始的想法和线索也很好,我只需要从某个地方开始。
Let me know if you need any more information or clarification, as I'm not sure which kind of information you need for this. 如果您需要更多信息或澄清,请告诉我,因为我不确定您需要哪种信息。
Visual WebGUI has a built in Upload mechanism, called the UploadControl. Visual WebGUI具有内置的上载机制,称为UploadControl。
Since you're using VWG, you should check out the Companion Kit which is one of few remaining resources out there for Visual Web Gui. 由于您使用的是VWG,因此您应该检查Companion Kit ,这是Visual Web Gui剩余的少数资源之一。 It gives an example of the upload control.
它提供了上载控件的示例。 It also gives example code, which you can download.
它还提供了示例代码,您可以下载它们。
In short, what happens is that VWG will handle the JS components of getting the file. 简而言之,发生的事情是VWG将处理获取文件的JS组件。 You don't have to worry about JavaScript, that's the point of VWG.
您不必担心JavaScript,这就是VWG的重点。 In C#, you'll code the UploadControl, and what you "get" is the information about the file like Name, Size, MIME type, etc. Refer to the companion kit for info on this.
在C#中,您将对UploadControl进行编码,“获取”的是有关文件的信息,例如名称,大小,MIME类型等。有关此信息,请参阅配套工具包。
Steps: 脚步:
1) Add the UploadControl to a form 1)将UploadControl添加到表单
this.mobjUploadControl = new Gizmox.WebGUI.Forms.UploadControl();
2) Wire up the UploadControl 2)连接UploadControl
this.mobjUploadControl.UploadFileCompleted += new Gizmox.WebGUI.Forms.UploadFileCompletedHandler(this.mobjUploadControl_UploadFileCompleted);
3) Handle the actual upload. 3)处理实际上传。
private void mobjUploadControl_UploadFileCompleted(object sender, UploadCompletedEventArgs e)
{
UploadFileResult uploadedFile = e.Result;
// binary data for file, can be used to store to filesystem, db, etc
byte[] fileData = File.ReadAllBytes(uploadedFile.TempFileFullName);
// filename of what was uploaded
string fileName = uploadedFile.Name;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.