The above two function not working in wordpress. I want to download file and i am running wordpress in xampp also i have tried it in another online server with wordpress framework still not working.
but this is working in another online server where i have not used wordpress framework.
Is there is problem with wordpress using the above two function?
(below code just take get request which is the path to the file to be downloaded from the server and after validating token the path is given from database)
<?php
ini_set('display_errors', -1 );
require('wp-blog-header.php');
require('wp-config.php');
$token = ($_GET["token"]);
$platform = ($_GET["platform"]);
$resolution = ($_GET["resolution"]);
$assetName =($_GET["assetName"]);
$currentTime = date("ymdHi" , time());
if($wpdb->query("SELECT * FROM wp_token_table WHERE token='$token'")){
$result = $wpdb->get_results("SELECT (path) FROM wp_path_table WHERE os='$platform' AND res = '$resolution' AND bundle_name= '$assetName'");
if($result){
$path = $result[0]->path;
$fileName = basename($assetName);
$filePath = $path;
if(!empty($fileName) && file_exists($filePath)){
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: application/zip");
header("Content-Length:".filesize($filePath));
header("Content-Disposition: attachment; filename=$fileName");
header("Content-Transfer-Encoding: binary");
readfile($filePath);
exit;
}
}
}else echo "false";
?>