I think I've solved my problem - I don't store the whole pathway to the file in the db, hope the script works fine once it is online...
I think it should be also noted in the original tutorial that this scripts works basically for ANY type of files, not only for images.