Back to top

Autore Topic: Problemi ad aprire doc pdf su mac  (Letto 3874 volte)

Offline Cybassh

  • Esploratore
  • **
  • Post: 105
    • Mostra profilo
Problemi ad aprire doc pdf su mac
« il: 12 Lug 2011, 10:04:32 »
ciao a tutti,
  allora ho un altro problema mistico. la situazione è che se tento di scaricare un documento di qualsiasi genere:
da browser firefox e explorer, nessun problema. me lo apre con visualizzatore interno di firefox
se lo visualizzo con safari o opera, mi fa salvare nomefile.doc.html o nomefile.pdf.html

da cosa potrebbe dipendere?

p.s.
utilizzo una funzione del modello curriculum per determinare il mime types ed è:
Codice: [Seleziona]
public function daiMime($ext){
    $mime_types = array(

            'txt' => 'text/plain',
            'htm' => 'text/html',
            'html' => 'text/html',
            'php' => 'text/html',
            'css' => 'text/css',
            'js' => 'application/javascript',
            'json' => 'application/json',
            'xml' => 'application/xml',
            'swf' => 'application/x-shockwave-flash',
            'flv' => 'video/x-flv',

            // images
            'png' => 'image/png',
            'jpe' => 'image/jpeg',
            'jpeg' => 'image/jpeg',
            'jpg' => 'image/jpeg',
            'gif' => 'image/gif',
            'bmp' => 'image/bmp',
            'ico' => 'image/vnd.microsoft.icon',
            'tiff' => 'image/tiff',
            'tif' => 'image/tiff',
            'svg' => 'image/svg+xml',
            'svgz' => 'image/svg+xml',

            // archives
            'zip' => 'application/zip',
            'rar' => 'application/x-rar-compressed',
            'exe' => 'application/x-msdownload',
            'msi' => 'application/x-msdownload',
            'cab' => 'application/vnd.ms-cab-compressed',

            // audio/video
            'mp3' => 'audio/mpeg',
            'qt' => 'video/quicktime',
            'mov' => 'video/quicktime',

            // adobe
            'pdf' => 'application/pdf',
            'psd' => 'image/vnd.adobe.photoshop',
            'ai' => 'application/postscript',
            'eps' => 'application/postscript',
            'ps' => 'application/postscript',

            // ms office
            'doc' => 'application/msword',
            'docx'=> 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            'rtf' => 'application/rtf',
            'xls' => 'application/vnd.ms-excel',
            'ppt' => 'application/vnd.ms-powerpoint',

            // open office
            'odt' => 'application/vnd.oasis.opendocument.text',
            'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
        );

        //ext = strtolower(array_pop(explode('.',$filename)));
        if (array_key_exists($ext, $mime_types)) {
            return $mime_types[$ext];
        }
        /*elseif (function_exists('finfo_open')) {
            $finfo = finfo_open(FILEINFO_MIME);
            $mimetype = finfo_file($finfo, $filename);
            finfo_close($finfo);
            return $mimetype;
        }
else {
            return 'application/octet-stream';
        }
    }
}

ed uso il seguente codice nella vista per la creazione del file
Codice: [Seleziona]
<?php
// Impedisce l'accesso diretto al file
defined('_JEXEC') or die('Restricted access');

//require "./include/";

$model=& $this->getModel();
$document =& JFactory::getDocument();
$curriculum=$this->curriculum;

$tmp=$curriculum[0];
$blob=$tmp[blobdata];
$ext=$tmp[fileext];
$fs=$tmp[filesize];
$mime=$model->daiMime($ext);
/*if ($mime=="docx"){
 $mime= "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
}elseif($mime=="txt"){
    $mime="text/plain";
}else{
    $mime="application/$mime";
}*/
$header_cont="Content-Type: $mime";
$header_disp="Content-Disposition: attachment; filename=curriculum.$ext";


header('Content-Description: File Transfer');
    
header('Content-Disposition: attachment; filename="setup-wserver.zip"');
    
header('Content-Transfer-Encoding: binary');
    
header('Expires: 0');
    
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    
header('Pragma: public');
    
header('Content-Length: ' $fs);

$pippo=ob_get_clean();
$document->setMimeEncoding("$mime");
header("$header_disp");

echo 
$blob;

 



Web Design Bolzano Kreatif