title: How to upload and download files to/from mysql on PHP storing only path?
body: <p>I am uploading file by storing its path in mysql in that way: </p>
  
  <pre><code>if(isset($_FILES['filefield']))
      {
          $file = $_FILES['filefield'];
          $file_name = $file['name'];
          $file_size = $file['size'];
          $file_type = $file['type'];
          $file_tmpname = $file['tmp_name'];  
          $upload_dir = "C:/xampp/htdocs/intranet/www/public/uploads/";
          $ext_str = "gif,jpg,jpeg,mp3,tiff,bmp,doc,docx,ppt,pptx,txt,pdf";
          $allowed_extensions=explode(',',$ext_str);
          $max_file_size = 10485760;
          $ext = substr($file['name'], strrpos($file['name'], '.') + 1);
          if (!in_array($ext, $allowed_extensions))
              echo "only".$ext_str." files allowed to upload";
          if($file['size']&gt;=$max_file_size)
              echo "only the file less than ".$max_file_size."mb  allowed to upload";
          $path = $upload_dir.$file_name;
          if(move_uploaded_file($file_tmpname, $upload_dir.$file_name))
              ORM::factory('files')-&gt;uploadFile($teacher_id, $file_name, $file_size, $file_type, $path);
          else
              echo "The file cant moved to target directory.";
  
      }
  </code></pre>
  
  <p>How can I then download this file by its path? If my upload code is correct, of course. </p>