php headers doesn't downloads -


i trying make "force download" via php, strange symbols.

i tried add header ("application/typeofmyfile") , header ("content-disposition")... , many others many other post here, nothing

i've got this:

$f_location = "path/myfile.nl2pkg"; $f_name = "myfile.nl2pkg";   header("content-type: application/octet-stream"); header("content-disposition: attachment; filename=".$f_name); //here tried basename($f_name) nothing header("content-length: ".filesize($f_location));     header("content-transfer-encoding: binary"); 

i'm doing because when user clicks on "download" button, ajax send him page force download, put data in db , refresh main page.

it's first time working on headers, , read, don't know if i'm doing wrong.

your headers code seems fine. problem seems somewhere else.

to debug code use headers_sent determine if headers have been sent. can use headers_list see headers have been sent.

if (headers_sent()) {   var_dump(headers_list());   die('headers have been sent');   exit; } 

if use right before define headers find source of problem.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -