As EEAA said, this is definitely an inode problem. This is something you need to fix at a filesystem level. If you can't recreate the while filesystem, for example if you have all your data in one partition mounted at / [note: this is usually bad!], you can shrink the root filesystem, then create a second filesystem with appropriate inode counts from the free space, and mount it somewhere sensible (e.g. /var/www).
An ideal server will have multiple partitions for the different main filesystems. I recommend reading https://www.debian.org/releases/stable/amd64/apcs03.html.en as it's a good reference, if a little outdated: I prefer using ext4 /, /var, and /var/log partitions myself, with a "tmpfs" /tmp and additional data partitions as needed for different systems (e.g. /var/vmail on the mail server, /var/www on the web server, /home on desktops, etc.). Remember there are a lot of system files in / that contribute to your inode count!
Also ensure that those pictures have some sort of folder organization structure. Anything more than a few thousand files in one directory level (folder) tends to cause reads and "ls", etc. to choke in extX filesystems. You're best to organize them as much as you can before attmpting to upload.