Question: I have a website where users each have their own profile page. Here they can upload a single image that acts as their avatar. This is the only image users can upload to the server across the whole site. There is no archive so it can be overwritten if a user wishes to update their avatar.

I have never had to do anything like this before so I would like to open it up and ask for a suitable, scalable option for this website.

My initial thought is to give each user's image a random name, a string 6-12 characters long. This way you couldn't build a script that just pulls every user's profile pic from a directory (eg 001.png, 002.png etc). My second thought is that there should be only be a certain amount of images per directory to make sure they can be retrieved quickly by the server.

There may well be other things I'm missing here, I'm not sure on exact details hence why I'm asking.

Answer: 
I would recommend storing the images on something like Amazon S3. Depending on how many pictures you're storing, serving images can really take a tow on your web server. S3 is scalable and with multi-zone deployments through CloudFront (Amazon's version of a CDN), you can really speed up this part of your service.
I've been using base64 to store them within an SQL database. No need to manage files. It works well for relatively low resolution options.

How about not storing them as images at all?
You could leverage an external placeholder for each user, you could cache a random image from lorempixel.com: `http://lorempixel.com/100/100`. Use an MD5 hash of the user's name or ID. You could also just save the image using the user's ID, for example `442.jpg`.