Upload Files

With MX Kollection 3 you will be able to add file upload capabilities without any hand coding. The Transaction Engine handles both the table insert of the file name as well as saving to a specified folder on the server.

To use the file upload feature of MX Kollection 3, perform the following steps:

  1. Create an Insert/Update operation on your page. You can do this by using the Insert/Update Record Form Wizard, or by manually creating the form and adding the desired server behaviors. If you create the form manually, make sure that a file type form field is added and related to the table field that will store the file name, and that the form's enctype attribute is set to "multipart/form-data".
  2. Access the server behavior from the Application panel, Server Behaviors -> + -> MX Kollection -> File Upload -> Upload File.
  3. Configure the user interface to suit your particular needs.
  4. Save the page and test it into the browser by selecting a file to upload.

 

When submitting a page that has file upload capabilities added through MX Kollection, the Transaction Engine handles it in the following way:

  1. The Insert/Update transaction is executed first in order to add into the database all other fields, including the file name field.
  2. The file upload is executed only after the insert or update operation ended successfully. If the transaction failed due to any reason, the file upload will not take place.
  3. When attempting to move the uploaded file to the folder specified in the File Upload configuration, the Transaction Engine will also handle the following errors:

    · the possibility that a file with the same name has already been uploaded, by performing the action specified in the User Interface: Block or Rename.
    · the file size is bigger than the maximum specified in the user interface, by stopping the file upload.
    · the file extension does not match any of those in the list of allowed extensions, in which case the upload fails.
                                     
  4. If no other errors were raised when uploading the file, everything ends here. Otherwise, if the file upload fails, a rollback will be performed on the transaction, so that no invalid data will be stored in the table.

 

If you've already worked with MX Kollection 2 and it's File Upload capabilities, here are some enhancements brought by the third version:

  1. File name is now preserved so downloading it is easier

  2. When uploading a new file, an automatic check of the existing files is made, and if a conflict arises, it automatically renames the new file to avoid any further problems or blocks the upload, depending on the developer's choice

  3. Define file extensions to be allowed when uploading files, so that the security of your server will not be compromised

  4. The maximum size for the uploaded files can also be set when adding the capabilities to the form.

 

This section contains the following topics: