0

I am really wonder about with case. I have never met before this situation. I have a file download process that mean: user can select a file from a list, then press the download button and a small popup window appear to download the file...or it should be appear.

In the development environment everything is fine but the production server is something wrong, because after the pushed the download button the process display the content of the file.

I use the following header settings:

'Content-type': 'application/Octet-stream'
'Content-Disposition: ': 'attachment; filename='.$file
'Content-Length: ': filesize($path.$file)
'Content-Description': 'File Transfer';

I tried to use text/plain to content-type, then this settings, but it is not helped me :(

Questions:

  • is it possible that the problem could be with the file extension? This file extension is: cfg - I think not because the download process is working in developer environment.
  • is it possible that needs some Apache settings/modification?

(I use Symfony2 framwork, PHP version: 5.3.10)

Please help!

Thank you!

aBanhidy
  • 257
  • 1
  • 3
  • 11
  • Without knowing too much about your environment I'd say 1) if you want to view the content of the file you'll need the text/plain content-type ( as you suggest ) 2) you'll need to register the Mime Type in your Apache configuration on the production server – splig Sep 08 '14 at 09:03
  • You can find most information with this answer. http://stackoverflow.com/questions/3599670/ajax-file-download-using-jquery-php?answertab=votes#tab-top – Baptiste Donaux Sep 08 '14 at 09:11
  • I tried that I modify the file extension from cfg to txt...and it is not work...and try to add AddType to .htaccess file :( – aBanhidy Sep 08 '14 at 10:57

1 Answers1

0

Try creating a .htaccess file in the same directory as the file with you code in your question with the following:

AddType application/octet-stream .cfg
GeorgeQ
  • 1,382
  • 10
  • 8