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

  • SEARCH
  • Home
  • 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 6234645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:31:24+00:00 2026-05-24T10:31:24+00:00

I have a real strange behavior when sending a zip archive containing a any

  • 0

I have a real strange behavior when sending a zip archive containing a any type of file in symfony.
The problem is that the zip file, that I download from the browser contains an extra ‘bit’ at the beginning of the file.

Here’s my code:

$tmpFileName = tempnam("/tmp", "xb_");
$zip = new ZipArchive();
$zip->open($tmpFileName, ZipArchive::CREATE);
$zip->addFile('[directory_inside_webspace]/test.pdf', 'myTest.pdf');
$zip->close();
$this->getResponse()->clearHttpHeaders();
$this->getResponse()->setContent(file_get_contents($tmpFileName));
$this->getResponse()->setHttpHeader('Content-Type', 'application/zip');
$this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename=archive.zip');
return sfView::NONE;

Now here’s what is strange. The temporary zip file under /tmp is fine. I can extract it without any problems.
But the file the browser sends to me is corrupt. When I open both of them in hex editor, the first few bytes look like:

working file:      50 4B 03 04 14 00 00 
corrupt file:   0A 50 4B 03 04 14 00 00

When I remove the addition ‘0A’ from the corrupt file I can open it without problems.
It’s now the exactly same file as the tmp file created in /tmp.

Did anyone had a behavior like this before?? I’m stucked at this problem for over 4 days now and I’m not able to find the error.
I use exactly the same code in another symfony module and it’s working in there. Any ideas ?

—–Update——

The problem wasn’t related to the zipArchive or setContent.
I had a query at the beginning of the function.

$bill = Doctrine::getTable('Bill')->find($request->getParameter('id'));

In the class ‘Bill.class.php’ in my doctrine model I had a blank line before

<?php

So when the class Bill was instantiated the new line was print to screen.

I just wonder why php doesn’t give an error message like ‘headers already send’ when sending the zip Archive to the browser.

  • 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-24T10:31:25+00:00Added an answer on May 24, 2026 at 10:31 am

    0A is a newline character. Make sure there’s no newline before the <?php tag of all the files involved, and no newline after the ?> tag (unless you omit the closing tag, which is recommended).
    The most probable culprit is the actions.class.php of the download action.

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

Sidebar

Related Questions

strange problem with php on windows... my application loads a 'core' file that loads
I've been having a strange problem that I've never seen before. Now I have
I am experiencing a strange problem: I have a Screen that is using the
First, why I ask: Now that reputation points on StackOverflow have real value (you
Do bubble sorts have any real world use? Every time I see one mentioned,
Does anyone know how sites that have a real-time feed of a lot of
I have a function that expects real numbers (either integers or floats) as its
I have a strange problem with codeigniter upload class. I use uploadify (http://www.uploadify.com) to
I have a strange problem. To detect outgoing calls I have registered a broadcast
I'm having a real strange problem using GCC for ARM with the optimizations turned

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.