hello,
i need help with the following.
I have to export data from a db to a file.csv. So far is ok, but i don't know how i could save the file to users computer.
Could someone pls guide me?
save file to user comp
Moderator: General Moderators
You can't
You can't directly. You either have to sent the file data with the appriate header or you have to just out the stuff you their browser and have them copy and paste. I'd do the former, probably like this:
There is a header you should output to tell the browser what the file is called, but I don't remember it right now.
Code: Select all
<?php
// Note that there can be no output (even spaces!) before the next line
header('Content-type: text/cvs');
// Put the cvs file contents here
// Example:
echo "asdf,iojwefioe,wefoiwjef\n";
echo 'wioefje,woefjeifo,jioj';
?>