IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Conception Web Discussion :

Telechargement de fichier crypté ou illisible


Sujet :

Conception Web

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Femme Profil pro
    Inscrit en
    Février 2012
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Février 2012
    Messages : 28
    Par défaut Telechargement de fichier crypté ou illisible
    Bonjour a tous,

    J'ai un problème avec le téléchargement de fichier.
    Lorsque je clique sur le lien de téléchargement d'un fichier .doc ou .xls, le navigateur m'ouvre le fichier mais crypté. Ya des signes bizarres
    Et lorsque j'essai d'ouvrir des fichiers images (.png et .jpg), il m'ecrit : 'La visionneuse de photos Windows ne peut ouvrir cette image car le fichier semble endommagé ou corrompu, ou il est trop grand'. Alors qu'il n'est rien de tout cela.

    Voici ma fonction de telechargement :

    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
    public function telechargerFichier ($file)
        {
            if (! is_file($file)) {
                throw new Zend_View_Exception('Fichier : ' . $file . ' inexistant');
            }
            
            $len = filesize($file);
            echo 'taille fichier : '.$len;
            
            $filename = basename($file);
            $file_extension = strtolower(substr(strrchr($filename, "."), 1));
    
            switch ($file_extension) {
                case "pdf":
                    $ctype = "application/pdf";
                    break;
                case "exe":
                    $ctype = "application/octet-stream";
                    break;
                case "zip":
                    $ctype = "application/zip";
                    break;
                case "doc":
                case "docx":
                    $ctype = "application/msword";
                    break;
                case "xls":
                case "xlsx":
                    $ctype = "application/vnd.ms-excel";
                    break;
                case "ppt":
                case "pptx":
                    $ctype = "application/vnd.ms-powerpoint";
                    break;
                case "gif":
                    $ctype = "image/gif";
                    break;
                case "png":
                    $ctype = "image/png";
                    break;
                case "jpeg":
                case "jpg":
                    $ctype = "image/jpg";
                    break;
                case "mp3":
                    $ctype = "audio/mpeg";
                    break;
                case "wav":
                    $ctype = "audio/x-wav";
                    break;
                case "mpeg":
                case "mpg":
                case "mpe":
                    $ctype = "video/mpeg";
                    break;
                case "mov":
                    $ctype = "video/quicktime";
                    break;
                case "avi":
                    $ctype = "video/x-msvideo";
                    break;
                case "php":
                case "htm":
                case "html":
                case "txt":
                    die("<b>Cannot be used for " . $file_extension . " files!</b>");
                    break;
                default:
                    $ctype = "application/force-download";
            }
    
            header("Pragma: public");
            header("Expires: 0");
            header("Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0");
            header("Cache-Control: public");
            header("Content-Description: File Transfer");
            header("Content-Type: $ctype");
            $header = "Content-Disposition: attachment; filename=" . $filename . ";";
            header($header);
            header("Content-Transfer-Encoding: binary");
            header("Content-Length: " . $len);
            @readfile($file);
            exit();
        }

    Aidez moi s'il vous plait =)

  2. #2
    Membre Expert
    Avatar de transgohan
    Homme Profil pro
    Développeur Temps réel Embarqué
    Inscrit en
    Janvier 2011
    Messages
    3 149
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Maine et Loire (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur Temps réel Embarqué

    Informations forums :
    Inscription : Janvier 2011
    Messages : 3 149
    Par défaut
    Enlève le premier echo. ^^'

  3. #3
    Membre averti
    Femme Profil pro
    Inscrit en
    Février 2012
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Février 2012
    Messages : 28
    Par défaut
    non mais je l'ai mis pour voir si ça marchait bien

    C'est pas ça le problème :/

  4. #4
    Membre averti
    Femme Profil pro
    Inscrit en
    Février 2012
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Février 2012
    Messages : 28
    Par défaut
    nan c'est bien ca
    Je me suis trompé de fichier

    MERCI BEAUCOUP ! =)

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Wget - télécharger des fichiers non-html
    Par narmataru dans le forum Réseau
    Réponses: 10
    Dernier message: 14/07/2018, 15h20
  2. Telechargement de fichier
    Par ArkAng3 dans le forum MFC
    Réponses: 1
    Dernier message: 31/10/2005, 11h32
  3. [Telechargement de Fichier] Recherche balise adéquate
    Par Kylen dans le forum Balisage (X)HTML et validation W3C
    Réponses: 3
    Dernier message: 12/09/2005, 15h21
  4. telecharger un fichier
    Par mokha8581 dans le forum Langage
    Réponses: 2
    Dernier message: 10/09/2005, 14h15
  5. [VB6] Télécharger un fichier avec VB 6
    Par lechevbt dans le forum VB 6 et antérieur
    Réponses: 4
    Dernier message: 18/02/2004, 20h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo