How to download php file?

So, I have this on my PHP script on my test site:

$file="clip.mp4"; $fake="clip_testing.mp4"; $fsize = filesize($file); header("Content-Length: $fsize"); header("Content-Disposition: attachment; filename=$fake"); header("Content Type: application/download"); set_time_limit(0); $fs = @fopen($file,"rb"); while(!feof($fs)) { print(@fread($fs, 1024*8)); ob_flush(); flush(); } 

When I use this in a link and upload a file, the first 7 bytes of my files change. Therefore, I need to edit the program before I can use it. I added a picture to make it clearer about what I'm talking about when I say that the first 7 bytes have changed. Am I missing the headlines? Can someone help me? Comparison

EDIT: If you have problems viewing the image due to its size, look at the image in a new tab without formatting so that it is original.

+4
source share
1 answer

I think you have 4 empty lines before the <?php tag.

These are 8 bytes - these are 4 times line breaks \r\n .

+8
source

Source: https://habr.com/ru/post/1399125/


All Articles