Jump to content

afterfx

New Members
  • Posts

    1
  • Joined

  • Last visited

afterfx's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello guys, i do not have very good PHP knowledge so go easy on me So I am building this site, where users can create files (for now only text files) Creating file is done and works, now I want to add function to download the file, my code so far <?php error_reporting(E_ALL); $file = $_GET['file']; if(file_exists('users/'.$_COOKIE['username'].'/files'. '/' .$file)) { header('Content-Type: text/plain'); $content = file_get_contents('users/' . $_COOKIE['username'] . '/files' . '/' .$file); //var_dump($content); //die(); header('Content-Disposition: attachment; filename="'.$file.'"'); readfile($file); } else { echo "File does not exists!"; } ?> I have 5 files 1.txt 2.txt 3.txt ... 5.txt. Download part works alright, but the file downloaded is blank If i var_dump the file i get the following : string(4) "Five" for the 5.txt and string(3) "Two" for the 2.txt I know that the code is awful to look but I am not that experienced in coding. Am I missing some headers?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.