I have a base64 encoded string converted with the php function below.
public function convert_image_to_base64($file_path){
$mime = get_mime_by_extension($file_path);
$data = file_get_contents($file_path);
return 'data:'. $mime . ';base64,' . base64_encode($data);
}
I want to download the file in a browser with the below html
<a href="<?= $base64_file ?>" target="blank">Download</a>
When I click, the link downloads a zip file.
This is the start of the resulting base64 string
data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,UEsDBBQABgAIAAAAI
I want to download the exact .docx or .doc file uploaded
I searched on stackoverflow and other forums but none of them address this exact problem. I also don't want to decode the file before submitting the html.