Ecommerce Shopify WordPress Discussion

WordPress: Creating txt file in PHP

I try to create a txt file : $upload_dir = wp_upload_dir(); // because Wordpress $filename = $upload_dir["basedir"] . "/export.txt"; $file = fopen($filename, "w"); // or die("Unable to open file!"); $length = strlen($content); header("Content-Type: text/plain"); header('Content-Disposition: attachment; filename='.basename($filename)); header('Content-Length: ' . filesize($file)); header('Content-type: text/tab-separated-values'); header('Content-Description: File Transfer'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); readfile($file); fclose($file); The file is created correctly but at the same time I download the file and its content is the HTML of the page I am on. I want to download the correct file.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.