mikcsu120 Posted November 13, 2021 Share Posted November 13, 2021 Hi! There's this code which I have function pushfile(&$file) { header_remove(); if (isset($file["type"])) header('Content-Type: '.$file["type"]); if (isset($file["name"])) header('Content-Disposition: attachment; filename="'.$file["name"].'"'); print $file["name"]; header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: "); echo $file["content"]; exit; $h=fopen($filename,"r"); $content = fread($h, filesize($filename)); fclose($h); $file["type"] = "application/"; // $file["name"] = $real_filename; $file["content"] = $content."*".$context['user']['id']; pushfile($file); This ID number was well placed into the downloaded file, but it disappeared after converting it (e.g. from pdf to epub). Is there a good solution for that? Quote Link to comment https://forums.phpfreaks.com/topic/314217-appearance-of-user-id-when-downloading-to-the-file/ Share on other sites More sharing options...
kicken Posted November 13, 2021 Share Posted November 13, 2021 4 hours ago, mikcsu120 said: $file["content"] = $content."*".$context['user']['id']; Your adding the ID to the content of the file right there. If you don't want the ID number in the file, then don't add it. $file['content']=$content; Quote Link to comment https://forums.phpfreaks.com/topic/314217-appearance-of-user-id-when-downloading-to-the-file/#findComment-1592007 Share on other sites More sharing options...
mikcsu120 Posted November 16, 2021 Author Share Posted November 16, 2021 (edited) thanks for the reply. How to put it in the middle of the content? Edited November 16, 2021 by mikcsu120 Quote Link to comment https://forums.phpfreaks.com/topic/314217-appearance-of-user-id-when-downloading-to-the-file/#findComment-1592166 Share on other sites More sharing options...
Psycho Posted November 17, 2021 Share Posted November 17, 2021 15 hours ago, mikcsu120 said: How to put it in the middle of the content? Probably not what you really want, but it is what you asked for: $midPt = floor(strlen($content)/2); $file["content"] = substr($content, 0, $midPt) . $context['user']['id'] . substr($content, $midPt); 2 Quote Link to comment https://forums.phpfreaks.com/topic/314217-appearance-of-user-id-when-downloading-to-the-file/#findComment-1592177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.