A thought occurred to me: does $file contain the full path to the file?, if it doesn't, then perhaps MySQL can't find the file you're looking for.
The reason it works in the CLI could be that you're running the CLI from the correct directory
Hope this helps
davis
Is this going out live?
No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist