Victor Morozan

Victor Morozan

  • NA
  • 31
  • 497

I can not see the contents of the file after downloading?

Feb 28 2019 2:16 AM
I have a database that is storing all my pdf files for a website.
 
$params['name'] = $fields['title_name'];
$params['parent_id'] = $fields['uid'];
$params['name_file'] = strtolower($_FILES['fileToUpload']['name']);
$params['size_file'] = $_FILES['fileToUpload']['size'];
$params['type_file'] = $_FILES['fileToUpload']['type'];
 
!empty($_FILES) ? $params['data_file'] = base64_encode(file_get_contents($_FILES['fileToUpload']['tmp_name'])) : null;
 
Below you see the time of downloading the file, but when I open it I'm having an error that it is not content.
 
while($row = $this->db->getRow($result)) {
   $type = $row['type_file'];
   $size = $row['size_file'];
   $filename = $row['name_file'];
   $content = file_get_contents(''.$filename.'', base64_decode($row ['data_file']));
   
   header("Content-length: $size");
   header("Content-type: $type");
   header("Content-Disposition: download; filename=$filename");
   
   echo $content;
}

Is there a way we can do this?

The reason is that I do not want to use moveuploaded file into a folder.

Thank you.


Answers (1)