php - Downloaded pdf file unable to be opened - improper encoding? -
i'm unsure how approach solving problem. have link when clicked downloads file users machine. file pdf. if copy , paste file onto desktop , open copy, works fine. yet when user downloads , tries open, this:
here code:(fyi: have validation on filename before this..)
$file_name = $dat->filename; //'file.avi'; $file_url = $dat->path . $dat->url . $filename; header('content-type:'. $dat->type); header("content-disposition: attachment; filename=\"" . $file_name . "\""); header("filename=\"" . $file_name . "\""); readfile($file_url); exit; i have tried multiple headers nothing seems work. doing wrong encoding? seems me file valid , should simple copy users machine copy made locally worked fine.
update
i opened file per marcin's suggestion, in sublime. get.. no body?
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <link rel="stylesheet" type="text/css" href="/assets/jquery/jquery-ui-1.12.1/jquery-ui.min.css"> <script src="/assets/jquery/jquery-3.2.1.min.js"></script> <script src="/assets/jquery/jquery-ui-1.12.1/jquery-ui.min.js"></script> <script src="/assets/pdfobject/pdfobject.js"></script> <style> body{ overflow: hidden; } .pdfobject-container { height: 99vh; overflow: hidden; } </style> <title></title> </head> <body>
i'd open file in i.e. text editor or binary editor , see what's inside. blind guess you find there sort of i.e. php notice/error message or polluting data other way.

Comments
Post a Comment