title: Audio files to be stored into database
body: <p>Prior to this link:<a href="https://stackoverflow.com/questions/154707/what-is-the-best-way-to-store-media-files-on-a-database">What is the best way to store media files on a database?</a> </p>
  
  <p>The answer stated:</p>
  
  <p>(
  Every system I know of that stores large numbers of big files stores them externally to the database. You store all of the queryable data for the file (title, artist, length, etc) in the database, along with a partial path to the file. When it's time to retrieve the file, you extract the file's path, prepend some file root (or URL) to it, and return that.
  )</p>
  
  <p>My questions are: </p>
  
  <p>a)How do you store the partial path of the file? </p>
  
  <p>b)How do you extract the file's path?</p>
  
  <p>c)How do you prepend some file root and return it?</p>
  
  <p>(Sorry I am very new and this bit I don't quite get. Any input or examples would be lovely.)</p>
  
  <p>Btw, these are my codes for uploading the file, I just don't know the retrieve bit.</p>
  
  <pre><code>&lt;?php
  if(isset($_FILES['uploaded_file'])) {   
  
  if($_FILES['uploaded_file']['error'] == 0) {
      // Connect to the database
      $dbLink = new mysqli('localhost', 'root', '', 'spellingbee');
      if(mysqli_connect_errno()) {
          die("MySQL connection failed: ". mysqli_connect_error());
      }
  
      // Gather all required data
      $name = $dbLink-&gt;real_escape_string($_FILES['uploaded_file']['name']);
      $location = $dbLink-&gt;real_escape_string($_FILES['uploaded_file']['location']);
      $data = $dbLink-&gt;real_escape_string(file_get_contents($_FILES  ['uploaded_file']['tmp_name']));
      $size = intval($_FILES['uploaded_file']['size']);
  
      // Create the SQL query
      $query = "
          INSERT INTO `file` (
              `name`, `location`, `size`, `data`, `created`
          )
          VALUES (
              '{$name}', '{$location}', {$size}, '{$data}', NOW()
          )";
  
      // Execute the query
      $result = $dbLink-&gt;query($query);
  
      // Check if it was successfull
      if($result) {
          echo 'Success! Your file was successfully added!';
      }
      else {
          echo 'Error! Failed to insert the file'
             . "&lt;pre&gt;{$dbLink-&gt;error}&lt;/pre&gt;";
      }
  }
  else {
      echo 'An error accured while the file was being uploaded. '
         . 'Error code: '. intval($_FILES['uploaded_file']['error']);
  }
  
  // Close the mysql connection
  $dbLink-&gt;close();
   }
   else {
  echo 'Error! A file was not sent!';
   }
  
   // Echo a link back to the main page
    echo '&lt;p&gt;Click &lt;a href="form.html"&gt;here&lt;/a&gt; to go back&lt;/p&gt;';
   ?&gt;
  </code></pre>