Bonjour,

Je dois permettre à mes utilisateurs de télécharger des fichiers .zip sur mon site. Tous marchait bien pendant dans année et l'à pour une raison inconnue, lorsqu'on télécharge les fichiers ils deviennent corrompu...

Exemple d'URL
Code : Sélectionner tout - Visualiser dans une fenêtre à part
...a.php?id=100&type=ftp
Voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
 
class Downloader
{
    var $prod;
    var $client;
    var $type;
 
    public function __construct(Client $client, Product $prod, $type = 'ftp')
    {
        $this->prod = $prod;
        $this->client = $client;
        $this->setType($type);
    }
 
    public function setType($type)
    {
        if ($type == 'http')
            $this->type = 'http';
        else
            $this->type = 'ftp';
    }
 
    public function launchDownload($type = null)
    {
        if ($type)
            $this->setType($type);
        $this->entreeHistorique();
        if ($this->isFileAccessible())
        {
            $this->applyHeaders();
            $this->readFile();
        }
        else
            throw new Exception('Fichier indisponible via ' . $this->type . '.');
    }
 
    private function isFileAccessible()
    {
        switch ($this->type)
        {
            case 'http':
				system("net use --CHEMIN-- ");
 
                return file_exists("W:\fichier\\" . $this->prod->getNomFichier());
                break;
            default:
                return file_exists($this->prod->getFichier());
                break;
        }
    }
 
    private function readFile()
    {
        switch ($this->type)
        {
            case 'http':
                $fichier = "W:\fichier\\" . $this->prod->getNomFichier();
                header('Content-Length: ' . filesize($fichier));
                readfile($fichier) or die('Fichier indisponible');
                break;
            default:
                header('Content-Length: ' . filesize($this->prod->getFichier()));
                readfile($this->prod->getFichier()) or die('Fichier indisponible');
                break ;
        }
    }
 
    private function applyHeaders()
    {
        header('Content-Disposition: attachment; filename=' . $this->prod->getNomFichier());
        header('Content-Type: application/force-download');
        header('Content-Transfer-Encoding: binary');
        header('Pragma: no-cache');
        header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
        header('Expires: 0');
        ini_set('max_execution_time', 0);
    }
 
    private function entreeHistorique()
    {
       add à l'historique
    }
 
}
Merci beaucoup