Skip to main content

Button Upload Action

  1. Navigate to HSYCO Manager

  2. Create a new project or open an existing one

  1. Go to the Home page

  1. Click "add"

  1. Add a "Button"

  1. Go back to "edit" mode

  1. Align the button by clicking "Align" and then "Center Horizontally" and "Center Vertically"

8. Give the button an ID ("uploadbutton" for example). This is very important because we'll use it later to set a dynamic attribute that cannot be set from the Project Editor

  1. Change the "Label" to "Upload"

  1. Change the "Description" to "Click to upload files"

11. Change the "Action" to "upload". The "Multiple" checkbox can be checked if you want to be able to upload multiple files at once. By default, one file at a time is uploaded

  1. The page should look like this:

  1. Click "Save" to save the project

Tip: Great! Now we need to set with some code the dynamic attribute I was talking about in Step 8

  1. Go to "File Manager"

  1. Create a new folder by clicking "New Folder"

16. Give the folder a name ("test" for example). This is the folder where we will save our file uploaded

  1. As you can see, the folder has been created

  1. Now open the directory "events"

  1. Click "New File"

  1. Give it a name ("upload.txt" for example) and click "New File"

**21. Now copy one the following two code snippets into the file and save it:

INIT : {
uiSet("uploadbutton", "path", "test");
}

OR

INIT : UISET uploadbutton.path = test

The first one is JavaScript while the second is Events but they do the same action. What this does is it tells the button with ID "uploadbutton" to upload the files under the /test directory by setting the "path" attribute to "test"**

Tip: Now we can try the button!

  1. Re-open the project, click "Run" and then "Default" to launch the application

  1. Click the button

24. The popup shows up. Select a file to upload to the "test" folder

  1. Click "Upload"

  1. When it finishes, click "Ok"

  1. Now go to the "File Manager" to check if the file exists

  1. Go into "test"

29. The file has been successfully uploaded. You can open it by double clicking on his name