This is the scripting i have done for upload image buttton in Scada and also selected the image component named imgStudent. The image path is displaying in preview mode but the image that i am selecting is not get displayed in dashboard. I've given the attribute. Selected in 2nd last line of code but it's not working so which attribute should i give to display the image.
# Import the system module
import system
# Open the file dialog to select an image from the PC documents directory
filePath = system.file.openFile()
fileFilter="Image Files (*.png;*.jpg;*.jpeg) |*.png;*.jpg;*.jpeg; *)"
event.source.parent.getComponent('Mypath').text = filePath
#event.source.parent.getComponent('ImgStudent').source = filePath
imageBytes = system.file.readFileAsBytes(filePath)
imageComponent = event.source.parent.getComponent('ImgStudent').Selected
imageComponent = imageBytes
This code is just assigning the Selected property of the image component [which I'm not sure exists] to the variable imageComponent, and then immediately overwriting it with imageBytes.
Since this appears to be a file off of your local computer, I believe this is the code you need:
# Get the filepath for the image from the PC
filePath = system.file.openFile()
# Display the file path in a label by assigning it to the label's text property
event.source.parent.getComponent('Mypath').text = filePath
# Designate the file path as a file,
# and display the image in the image component
# by assigning the designated file path to the image component's path property
event.source.parent.getComponent('ImgStudent').path = 'file:///' + filePath