You could use substring, but it's so much easier just to use:
extractfilebase(str) - Extracts the base file name from a string. I.e: levels/file.nw would return file.
Usage:
PHP Code:
function onCreated() {
temp.filename = "fly.gani";
temp.gani = extractfilebase(temp.filename);
echo(temp.gani); // echos: fly
}