Have a look at the download resources section of my code snippets page
However, don’t use Download Resources in combination with the latest version of PsychoPy – though the test should still work
Each Frame
try {
psychoJS.serverManager.getResource(expInfo["participant"] + ".jpg");
continueRoutine = false;
} catch (e) {}