How to show a picture for each record

Hello Everybody

SERVOY NEWBEE !!!

I have a form (record view) where i show some employee informations.
Now i want to show an individual picture (photo) for each record from the file system.
Filename = employeeid.jpg (111111.jpg,4711.jpg,…)

I put an image controll(pnrpic) on my form and Onrecordselection i did:

var bildpfad = “file:///c:\programme\servoy\application_server\bilder\”;

//thisone also works with pictures in d:\bilder
//var bildpfad = “file:///\\computername\d$\bilder\”;

//thisone works with pictures in c:\programme\servoy\applic_server\server\webapps\root\bilder
//var bildpfad = application.getServerURL() + “/Bilder/”;

var bildname = utils.stringTrim(forms.visitenkarte.employeeid)+‘.jpg’;
var URL = bildpfad+bildname;
elements.pnrpic.setImageURL(URL);

But this only works with the smart-client.
I need a version which works with smart- and webclient !!!


I experimented with:
Formvariable pnrpic
Normal field controll type image_media dataprovider pnrpic

Onrecordselection i tried:
var bildpfad = “c:\programme\servoy\application_server\bilder\”;
var bildname = utils.stringTrim(forms.visitenkarte.employeeid)+‘.jpg’;
var persbild = bildpfad+bildname;
pnrpic = plugins.file.readFile(persbild);

No success ;-(

Where to put the pictures, so that they can be shown with smart- and webclient ??
How to code onrecordseletion?
Maybe there are employee records with no photos in the file system.
How to step over this (empty picture or default picture)

Best regards
Albert

The easiest by far is to create a binary field and just put the image in the record. Just put the field on screen and you are ready.

If you really want it on the filesystem make sure the files are in your web directory and get then in over http calls. Thats in yourservoydir/application_server/server/webapps/ROOT/