---
title: "Problem att skicka zip med PHP"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/171864-problem-att-skicka-zip-med-php"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "bohlin"
published: "2008-05-30T09:21:45.000Z"
updated: "2008-06-22T12:34:07.000Z"
replies: 2
views: 586
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/171864-problem-att-skicka-zip-med-php"
---

# Problem att skicka zip med PHP

## #1 — bohlin, 2008-05-30T09:21Z

Hej hej.
jag har ett script som försöker skicka en zip-fil.
Funkar jättebra med firefox, men sisådär i internet explorer 7.
På en testserver (HTTP) som jag har funkar det jättebra
, men på en annan server (HTTPS) så funkar det inte i internet explorer. Det som händer är att användaren får upp en ruta typ "Filen du försöker är inte tillgänglig" eller nått sånt.

Som sagt, det funkar i firefox både på testservern som kör HTTP och den andra HTTPS-servern, men explorer vill inte ta emot filen när jag testar på HTTPS-servern.

Nån som har någon teori?

```php
<?php
$zipfile = "/home/username/mapp/en-zip-fil-som-finns.zip";
$zipfilename = "hej.zip";

header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=" . $zipfilename ."");
header("Content-Length: " . filesize($zipfile));
header("Cache-Control: no-store, no-cache, must-revalidate");
readfile($zipfile);
exit;
?>
```

Permalänk: https://www.webforum.nu/p/171864

## #2 — Troxy, 2008-05-30T09:56Z

> If you are using the code for the Content-Length:
> 
> header("Content-Length: ".filesize($filepath));
> 
> Then this is the issue.  I don't know if it is with only certain servers, but in my case Internet Explorer couldn't get a filesize so it decided to not download any of the file.
> 
> The solution was to simply remove this line and give it no filesize and then the browsers would download the whole file.

<http://se.php.net/manual/en/function.readfile.php#82641>

Permalänk: https://www.webforum.nu/p/2116029

## #3 — bohlin, 2008-06-22T12:34Z

Hej.
Jag provade att ta bort header()-raden med content-length, men det funkade inte ändå. Men jag hittade till slut felet. I koden jag klistrade in hade jag missat en grej,  det är en session_start() överst!
session_start skickar ju en header med sessions-id, och den får INTE komma föra content-typ och content-length enligt internet explorer när man kör HTTPS. Om man kör HTTP så har IE inga problem med ordningen på header-raderna.

Alltså:
session_start();
header("Content-Type...");

funkar inte i IE över HTTPS, men detta funkar
header("Content-Type...");
session_start();

/johan

Permalänk: https://www.webforum.nu/p/2119453

---

Tråden på webben: https://www.webforum.nu/amne/php/171864-problem-att-skicka-zip-med-php
