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.
i have used different codes, but no one has worked.
PK����Uy�G��-j����P����_rels/.rels���������������������JA��>Ő{w�D��^D�Md}�0���;3!�}{���B)��������l>Hʔ��uӂ��s�����{Z݃)�)��98Q��n�B3j])���TF*FU~����"�&3�:��D�Z�`�d7m{g�'�Ls��`����6�b@E��Њ�n�N�ӡ�B�ϵ]Ή���^��^(����1��HI/y�Q) ו�����-�2�jY���9�%d����PK����Uy�G�I�����+����docProps/core.xml������������������m��j�@E�� ��-;�RL���J!��4�3������wb���R�sW���O�gq1�5-T(Z��ߞ�'�DM�f���e��~G�����c⬎�*� =�Ϊ�G:�7�"��3fo��y�d�ˌ���}D�j�Q�Wa�V#�+-�����E yb�A�������-..... And more.
this is my 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); } EDIT: I have already checked other questions with answers, but has not worked for me!