It depends upon how many users, how many simultaneous connections, how many files you want. If you aim petabyte data size things are always complex (see e.g. GlusterFS)!
I would generate the file name. You probably want to have hundreds of directories each having a few thousands files (and that depends a lot of the filesystem; ext4 is probably better than ext3). So something like dir034/file12345.jpeg
(and store that file path in some database).
Some old file systems have a linear complexity for the access of a given file in a large directory. And shells might be unhappy when dealing (e.g. auto-completion) with a directory of million files. Hence my advice to avoid directories with more than several thousands files!
You might handle very small contents (e.g. less than a kilobyte) differently, perhaps storing them directly in some database row...