Forum Moderators: coopster

Message Too Old, No Replies

How to download a winrar file via php

         

Gilead

5:51 pm on Mar 28, 2024 (gmt 0)

10+ Year Member



I need a php script that will take in an email and a password; then if correct download the winrar to the user. Have everything else working, bit missing something. When I tried, it put the contents of the winrar file on screen. Not what I was going for.
header('Content-Description: File Transfer');
header('Content-Type: application/win-rar'); // Set the Content Type for 'application/octet-stream' (binary file) or change it based on your specific file type
header("Content-Disposition: attachment; filename={$targetFile}");
readfile($targetFile);
exit;


What am I missing? Thanks!