I’m looking to build a backend for accepting user-uploaded images, renaming them and storing them in a file system (no, it’s not an Instagram)
I was thinking of simply renaming the image and storing in a user folder:
images/{userid}/{userid}_{md5(timestamp)}.jpg
The associations would also be included in the database.
Is that a good/sufficient model?
Essentially your method is just fine, but here are my suggestions to you:
file relationship. This way its easier to manage things like original
creation, last modified, or even expiration dates.
file on failure. Or if your order of operations is reversed, remove
the entry in the DB if the file fails to save to the server.
link (PHP file) with the filename as a GET variable. Then you can
check SESSIONS and/or COOKIES to determine if they are authorized to
view it. If they are, you can set the headers of the output to be
that of a jpeg or whatever kind of file they are viewing.