We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22683
    • 41 Posts
    Hello, i want to ask.. how to use header for download file in modx?? huh

    I use modx evolution 1.0.0 and make snippet for download file from ’assets/docs/’ rolleyes
    but i have problem.. results files after the download not the same as the original file or damage... undecided

    this my pieces snippet code.. wink

    if($status == 'download'){
      $id =$_GET['idfile'];
    	
      $query = $modx->db->query("SELECT * FROM uploadf WHERE id = '$id'");
      $data = mysql_fetch_array($query);
     
      $namefile= str_replace(" ","_",$data['name']);
    
      header("Content-Disposition: attachment; filename=".$namefile);
       
      header("Content-length: ".$data['size']);
      
      header("Content-type: ".$data['type']);
     
      
      $fp  = fopen("assets/docs/".$data['name'], 'r');
      $content = fread($fp, filesize('assets/docs/'.$data['name']));
      fclose($fp);
       
       
       
      return $content;
       
    }
    
    



    is there a solution to this problem or another way to download files... huh


    regards,


    syu11 smiley
      • 12320
      • 88 Posts
      why do you not use Eform ?

      regards
        Thanks to the authors of the following code :
        Easy Newsletter (module)
        SiteMap (snippet)
        Codepress (Plugins)
        Strict URLs (Plugins)
        Virtual Aliases (Plugins)
        Maxygallery (snippet)
        • 22683
        • 41 Posts
        Quote from: Focoweb at Nov 20, 2009, 03:43 AM

        why do you not use Eform ?

        regards

        grin I want to make my own snippets..

        rolleyes now my problem been solved.. should i use template blank for this header...

        grin sorry if my english bad...


        regards,

        syu11