Improve company productivity with a Business Account.Sign Up

x
?
Solved

do not want a forced download.  give user an option to click on a link

Posted on 2013-02-07
2
Medium Priority
?
272 Views
Last Modified: 2013-02-07
<?php 

 // Mime Type Checker
function get_mime($filename,$mode=0){

    // mode 0 = full check
    // mode 1 = extension check only

    $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',
        'rtf' => 'application/rtf',
        'xls' => 'application/vnd.ms-excel',
        'ppt' => 'application/vnd.ms-powerpoint',
        'docx' => 'application/msword',
        'xlsx' => 'application/vnd.ms-excel',
        'pptx' => '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(function_exists('mime_content_type')&&$mode==0){ 
    $mimetype = mime_content_type($filename); 
    return $mimetype; 
  }elseif(function_exists('finfo_open')&&$mode==0){ 
    $finfo = finfo_open(FILEINFO_MIME); 
    $mimetype = finfo_file($finfo, $filename); 
    finfo_close($finfo); 
    return $mimetype; 
  }elseif(array_key_exists($ext, $mime_types)){ 
    return $mime_types[$ext]; 
  }else { 
    return 'application/octet-stream'; 
  } 
}
$data = <<<EOD
UEsDBBQABgAIAAAAIQDd/JU3ZgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0
VMtuwjAQvFfqP0S+Vomhh6qqCBz6OLZIpR9g7A1Y9Uv28vr7bgJEVQtBKuUSKVnvzOzsxIPR2pps
CTFp70rW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AAAMQMAABwAAAAAAAAAAAAAAAAAwwYAAHdvcmQvX3JlbHMvZG9jdW1l
bnQueG1sLnJlbHNQSwECLQAUAAYACAAAACEAR3nK28cBAAD+AwAAEQAAAAAAAAAAAAAAAAD/CAAA
d29yZC9kb2N1bWVudC54bWxQSwECLQAUAAYACAAAACEAlrWt4pYGAABQGwAAFQAAAAAAAAAAAAAA
AAD1CgAAd29yZC90aGVtZS90aGVtZTEueG1sUEsBAi0AFAAGAAgAAAAhAOwes7UOAwAAGgcAABEA
AAAAAAAAAAAAAAAAvhEAAHdvcmQvc2V0dGluZ3MueG1sUEsBAi0AFAAGAAgAAAAhAK7eiquHAQAA
BwQAABIAAAAAAAAAAAAAAAAA+xQAAHdvcmQvZm9udFRhYmxlLnhtbFBLAQItABQABgAIAAAAIQBK
2IqSuwAAAAQBAAAUAAAAAAAAAAAAAAAAALIWAAB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQA
BgAIAAAAIQBf8SpWcQEAAMcCAAAQAAAAAAAAAAAAAAAAAJ8XAABkb2NQcm9wcy9hcHAueG1sUEsB
Ai0AFAAGAAgAAAAhADNnDBxIAQAAdQIAABEAAAAAAAAAAAAAAAAARhoAAGRvY1Byb3BzL2NvcmUu
eG1sUEsBAi0AFAAGAAgAAAAhADhjtEoSBwAA+DkAAA8AAAAAAAAAAAAAAAAAxRwAAHdvcmQvc3R5
bGVzLnhtbFBLBQYAAAAACwALAMECAAAEJAAAAAA=
EOD;

// REMOVE NEWLINE CHARACTERS
$arr  = explode(PHP_EOL, $data);
$data = implode(NULL, $arr);

// DECODE
$data = base64_decode($data);
$filename = 'welding.jpg';
$filename = 'Test_Words.docx';
$contentType = get_mime($filename);
header('Content-Type: '.$contentType.'; name="'.$filename.'"');
header('Content-Disposition: attachment;Filename="'.$filename.'"');
echo $data;
?>

Open in new window




running this code prompts the browser to download Test_Words.docx

I would like to allow the user to click on a link to download Test_Words.docx
0
Comment
Question by:rgb192
2 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 38866239
Instead of using header() and echo $data, just use file_put_contents() to write the $data variable into a file on the server, and echo the HTML <a> tag that points to the newly created file.
0
 
LVL 1

Author Closing Comment

by:rgb192
ID: 38867166
file_put_contents($filename,$data);
echo '<a href="'.$filename.'">'.$filename.'</a>';


thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

606 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question