Upload a picture

Upload a picture

  

Hello everyone ...


 I'm novice about this platform i wanted to know on how to upload a picture of 

* a certain type of extension, for example only accept 'jpeg', 'jpg'


* Maximum file storage allowed: 3.00 MB


If possible, I want to see an example that applies these conditions


Thank you...

Hello Arwa,

Unlike other Widgets, in Web Applications the File Upload Widget doesn't have Valid or Validation Message properties. You have to create your own custom validation.

Check this link that  you will find an example of how to do it after you just need to adapt for your situation

https://success.outsystems.com/Documentation/Development_FAQs/How_to_validate_file_input_on_a_File_Upload_Widget_in_a_Web_Application

and this one is how to use:

https://success.outsystems.com/Documentation/10/Developing_an_Application/Design_UI/Inputs/Enable_End-Users_to_Upload_Files

Hope I could help you

Cheers.

Hi Arwa,

Assuming you are creating a Web App, remember that uploading a file (any file, not just images), is a mechanism that is dicated by how the browser and HTML works, and not so much by how OutSystems specifically handles things. The way it works is that you select a file using the Upload Widget, and when you do a Submit (e.g. via a Button), the browser loads the file, and sends it to the server. On the server, your Web App's code runs, so that's the moment you can inspect things like the filename (to check for an allowed extension) or the file's size.

The Upload Widget has three Properties associated with it: Content (the actual binary content of the file), the Type, which is the MIME type (e.g. image/jpeg) and Filename, the name of the file:

You can check the size of the file by using the BinaryDataSize Action from the BinaryData Extension. You can check it's extension by checking the filename, but if you only allow images it's better to use the Type for the MIME type (you can Google the MIME types for other image types).

Kilian Hekhuis wrote:

Hi Arwa,

Assuming you are creating a Web App, remember that uploading a file (any file, not just images), is a mechanism that is dicated by how the browser and HTML works, and not so much by how OutSystems specifically handles things. The way it works is that you select a file using the Upload Widget, and when you do a Submit (e.g. via a Button), the browser loads the file, and sends it to the server. On the server, your Web App's code runs, so that's the moment you can inspect things like the filename (to check for an allowed extension) or the file's size.

The Upload Widget has three Properties associated with it: Content (the actual binary content of the file), the Type, which is the MIME type (e.g. image/jpeg) and Filename, the name of the file:

You can check the size of the file by using the BinaryDataSize Action from the BinaryData Extension. You can check it's extension by checking the filename, but if you only allow images it's better to use the Type for the MIME type (you can Google the MIME types for other image types).


Thank you Kilian Hekhuis


Is it possible to i see an example of this via Web please ?

Hi Arman,

This is all pretty basic OutSystems. Did you take the online training? If not, I'd advise you to take it so you better understand how OutSystems works.

Kilian Hekhuis wrote:

Hi Arman,

This is all pretty basic OutSystems. Did you take the online training? If not, I'd advise you to take it so you better understand how OutSystems works.


It might be basic for you but not for beginners. Point the requester to an example  / particular training will have been more useful and helpful. 

Solution

Ok, I'm sending an example, but for replicate this you need in your app go to manage dependencies, search for BinaryData click on it and you will need to check the BinaryDataSize in order to use it to get the size of your file, it will return the size in bytes so have that in mind when you use it. The remain is very self-explanatory, just see it in the UploadPhoto action of the PersonDetail screen.

Hope, I helped. 


Solution