title: How to download a file from server or local xampp? php
body: <p>I would like to download a .pptx file from my site folder to downloads or getting save as pop up where user can choose folder for save. but when i call my function, its printing in console.log a the content.</p>
  
  <p>i have used different codes, but no one has worked.</p>
  
  <pre><code>PK����Uy�G��-j����P����_rels/.rels���������������������JA��&gt;Ő{w�D��^D�Md}�0���;3!�}{���B)��������l&gt;Hʔ��uӂ��s�����{Z݃)�)��98Q��n�B3j])���TF*FU~����"�&amp;3�:��D�Z�`�d7m{g�'�Ls��`����6�b@E��Њ�n�N�ӡ�B�ϵ]Ή���^��^(����1��HI/y�Q)
  </code></pre>
  
  <p>ו�����-�2�jY���9�%d����PK����Uy�G�I�����+����docProps/core.xml������������������m��j�@E��
  ��-;�RL���J!��4�3��<code>����wb���R�sW���O�gq1�5-T(Z��ߞ�'�DM�f���e��~G�����c⬎�*� =�Ϊ�G:�7�"��3fo��y�d�ˌ���}D�j�Q�Wa�V#�+-�����E</code> yb�A�������-.....
  And more.</p>
  
  <p>this is my code:</p>
  
  <pre><code>        function downloadProject($file, $db)
          {
              $path = "../assets/convertables/Presentaties/"; // change the path to fit your websites document structure
              $dl_file = preg_replace("([^\w\s\d\-_~,;:\[\]\(\].]|[\.]{2,})", '', $file.'.pptx'); // simple file name validation
              $dl_file = filter_var($dl_file, FILTER_SANITIZE_URL); // Remove (more) invalid characters
              $fullPath = $path.$dl_file;
              header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
              header('Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation');
              header("Content-Transfer-Encoding: Binary");
              header("Content-length: ".filesize($fullPath));
              header("Content-disposition: attachment; filename=\"".$dl_file."\"");
              readfile($fullPath);          
          }
  </code></pre>
  
  <p>EDIT: I have already checked other questions with answers, but has not worked for me!</p>