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();
    }
?> 

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

How can i do that? How can i check the file type?

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.