0

I have a problem when downloading the file i've uploaded on my local server. The file is successfully downloaded, however there is a problem on opening the file that i've download.
For example i download a word file(.docx).

The error is : The office open XML file 'filename' cannot be opened because there are problems with the content. Word found unreadable content in 'my file.docx'.

and when i open the file on my download folder then on the file properties, there is something under the attribute says

"Security: This file came from another computer and might be block to help protect this computer." How can I also resolve that?? Please help

Here's my code for my download script

<?php
ob_start();
    if(isset($_GET['file'])){
        $file = $_GET['file'];
        $path = "lesson/".$file;
        header("Content-Disposition: attachment; filename=".$file);
        header("Content-Type: application/pdf");#pdf
        header("Content-Type: video/x-msvideovideo/x-msvideo");#avi
        header("Content-Type: video/x-flv");#flv
        header("Content-Type: video/mp4");#mp4
        header("Content-Type: application/vnd.ms-powerpoint");#ppt
        header("Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation");#pptx
        header("Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document");#docx
        while(ob_get_level()){
            ob_end_clean(); 
        }
        readfile("lesson/".$file);
        exit();
    }
?> 

Edited by jeffersonalomia

3
Contributors
5
Replies
32
Views
1 Year
Discussion Span
Last Post by jeffersonalomia
1

A file is unlikely to have all those content-types. It cannot be an mp4 AND a pdf. You need code to choose just one. You might also want to set the correct content-length. See the example:

http://php.net/readfile

Edited by pritaeas

0

Thank you. i have another problem. the size of the file change after download

Example. 55KB - original size
2KB - after download

why is that happen?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.