0

So I'm tasked to build a file upload for our application, which is using Visual WebGUI and therefore mostly looks like WinForms codewise.

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.

I tried google, but there's nothing on uploading something.

I don't understand enough of how websites work to even ask myself or google the right question. 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. 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).

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.

Squirrelkiller
  • 2,575
  • 1
  • 22
  • 41

1 Answers1

1

Visual WebGUI has a built in Upload mechanism, called the 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. 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. You don't have to worry about JavaScript, that's the point of 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.

Steps:

1) Add the UploadControl to a form

this.mobjUploadControl = new Gizmox.WebGUI.Forms.UploadControl();

2) Wire up the UploadControl

this.mobjUploadControl.UploadFileCompleted += new Gizmox.WebGUI.Forms.UploadFileCompletedHandler(this.mobjUploadControl_UploadFileCompleted);

3) Handle the actual upload.

  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;
  }
luxdvie
  • 902
  • 8
  • 16
  • Does the companion kit have an extra license? As far as we know, we only have the burial vwg licensed. – Squirrelkiller Aug 25 '17 at 20:43
  • I can't find any mention of license requirements in the documentation I have found. The guides I have found instruct users to copy that code exactly to learn VWG -- licensing concerns are not important to us, as we had a valid license when the product was around. When it was distributed, we were given resources that advised using the kit. Therefore, if you had a valid license, there is no reason to believe you're in any licensing conundrum. – luxdvie Aug 25 '17 at 20:58