Request.GetFileData() example
In this example, an uploaded image is directly read from the posted data and put into a personalization record.
The form used for uploading could look like this:
Smartsite SXML | Copy Code |
---|---|
<form method="post" action="{url.create(itemdata.number())}" enctype="multipart/form-data"> <label for="Photo">Select picture</label> <input name="Photo" id="Photo" type="file" /> <button type="submit">Update picture</button> </form> |
Here's the SXML used to get and store the image data.
Smartsite SXML | Copy Code |
---|---|
<se:format inputdata="{request.files()}" > <se:rowformat match="first"> {personalization.set('', Avatar, request.getfiledata(this.field(key)))} </se:rowformat> </se:format> |