I’m trying to use a regular expression along with the javascript search or test functions to test a file extension. The method, however, returns a “is not a function” for either the search or test functions (javascript, not servoy).
Here is the code:
// Message just to check script
var staffphotoupload = 'Choose';
application.setStatusText(staffphotoupload);
var staffphotoupload = plugins.file.showFileOpenDialog( '1','PATH REMOVED');
// Message just to check returned file path
application.setStatusText(staffphotoupload);
// checks for valid file extension
var staffphotoisimage = ""
var image_regExp = /\.(gif|jpg|png)/;
staffphotoisimage = staffphotoupload.test(image_regExp)
if (staffphotoupload && staffphotoisimage) //sets the field if valid
{
staffphotouploadfile = plugins.file.readFile(staffphotoupload)
fs_staffphoto = staffphotouploadfile
}
It works perfectly without the staffphotoisimage test - except of course that then a user can upload unwanted file types.
Any idea why its spitting this error out at me? I’ve used other javascript / regExp combos using replace and match successfully, but the search and test don’t seem to work correctly.
Thanks for any info or insight…its Friday, I’m tired of looking at it ![]()
Nolan M
FSCI