title: Best way to store large amount of data of users
body: <p>I store files of users in their own name directory something like </p>
  
  <pre><code>/username/file01.jpg
  /username/file02.mp4
  /username/file03.mp3
  </code></pre>
  
  <p>But if more users come and upload more files then this creates problem because this will lead to migration of some or many users to another drive.I choose username directory solution first because i dont want filenames to be mixed. I dont want to change filename too. Also if another user upload same filename then it creates problem ,if the files are stored with original name.</p>
  
  <p>What could be the best way to do this. I have one solution but want to ask community is this the best way .</p>
  
  <p>i will use sequential folders and then hash the file name to some thing very unique and store into the directory. 
  What i will do is store the original name of file and username into database and hashvalue of filename which is stored in Disk.</p>
  
  <p>When anyone want to access that file,I will read that file through php either replace the name or will do something at that point so that the file is downloaded as original filename.</p>
  
  <p>I have only this proposed solution in mind. Do you guys have any other better than this one.</p>
  
  <p>Edit:</p>
  
  <p>I use folder system too, and possibly for 2nd way i will use virtual folders.
  My database is MongoDB</p>
  
  <p><strong>Guys all your answers were awesome and really helpful. i wanted to give bounty to everyone, thats why i left it so that community can provide automatically. 
  Thanks all for your answers.I really appreciate it.</strong> </p>