Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5977965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:26:48+00:00 2026-05-22T21:26:48+00:00

I am having an issue in which the only filetype capable of being downloaded

  • 0

I am having an issue in which the only filetype capable of being downloaded correctly from the server is “.pdf”. Other files of other file types exist in the same location, upload perfectly fine, have the correct permissions, and load just fine when I scp them off to my local machine. I can’t show the entirety of the code involved since this is paid software, but honestly it seems that the problem shouldn’t even lie in the code itself…

I’ve tried re-writing the first function below with something similar to this: http://www.finalwebsites.com/forums/topic/php-file-download and then simply feeding it the correct values to make it pick specific files from the server. The files downloaded the same either way. They would show up as the correct file type with the correct name and even the correct size, but they would not open as anything but garbage values (unless a PDF). It is an apache server running freeBSD 8.2-RELEASE.

Either way, this is part of a class that is included by the code following it:

1600     function download_file($fileDir,$fileName,$instance_name)
1601     {
1602         $fileString=$fileDir.'/'.$fileName; // combine the path and file
1603         // translate file name properly for Internet Explorer.
1604     if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
1605     {
1606           $instance_name = preg_replace('/\./', '%2e', $instance_name,  substr_count($instance_name, '.') - 1);
1607     }
1608     // make sure the file exists before sending headers
1609 
1610     if(!$fdl=@fopen($fileString,'r'))
1611         {
1612            die("Cannot Open File!");
1613         }
1614     else
1615         {
1616           header("Cache-Control: ");// leave blank to avoid IE errors
1617           header("Pragma: ");// leave blank to avoid IE errors
1618           header("Content-type: application/octet-stream");
1619           header("Content-Disposition: attachment; filename=\"".$instance_name."\"");
1620           header("Content-length:".(string)(filesize($fileString)));
1621           sleep(1);
1622           fpassthru($fdl);
1623         }
1624     }

And now the code that uses it:

63         function download_att($supp_obj,$a_predefined) 64         {
65 
66             $get_vars=$a_predefined['get'];
67             $att_id=$get_vars['att_id'];
68             $article_attachment=$supp_obj->prefix_table("article_attachment");
69             $sql="select * from $article_attachment where att_id=$att_id";
70             $a_attach=$supp_obj->get_a_line($sql);
71 
72             $instance_name=$a_attach['attachment_name'];
73             $att_name_arr=split("\.",$instance_name);
74
75             list($n,$ext)=split("\.", $instance_name);
76
77
78             $fileName="kb_".$a_attach['article_id']."_".$att_id.".".$ext;
79             $fileDir="plugins/knowledgebase/attachments";
80             $supp_obj->download_file($fileDir,$fileName,$instance_name);
81         }
82 //----------------------------------------------------------------------------------------------------------------------
83 
84     if($a_predefined['get']['act']=="artattach")
85     {
86         download_att($supp_obj,$a_predefined);
87         exit;
88     }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:26:48+00:00Added an answer on May 22, 2026 at 9:26 pm

    What types are the other files? Are they supposed to be served as octet-streams as you’re doing?:

    header("Content-type: application/octet-stream");
    

    If, for example, you serve a text file with that header then how the browser interprets that file (or, more accurately, that response) may not be guaranteed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue building a grammar which is capable of parsing Python 3's
I am having a strange issue with the developer documentation (which i have only
i'm having an issue with creating a query in oracle which doesnt seem to
I'm having an issue when trying to do something which should be as easy
I am having an issue with the Color attribute for which I'm trying to
I'm currently having an issue storing mouse coordinates into an array in which a
I'm having an issue. I've implemented a PhaseListener, which is meant to add a
I'm having a weird issue with Internet Explorer which is not converting a valid
I am having the following issue : I have a table which looks like
I am having an annoying issue. I have a script which uses the $_GET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.