Answer the question
In order to leave comments, you need to log in
How to fix hook for FormIt?
There is a task so that when submitting a completed form, a file is downloaded, and then the user is redirected to another page. The file is loaded through the TV-field. I'm trying to do it with the download
hook :
$kp = $_SERVER['DOCUMENT_ROOT'];
$kp .= $modx->resource->getTVValue('kp');
if (file_exists($kp)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($kp).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($kp));
readfile($kp);
exit;
} else {
$modx->log(xPDO::LOG_LEVEL_ERROR, 'Нет такого файла');
}
return true;
Answer the question
In order to leave comments, you need to log in
remove redirect and try to put header with redirect manually before exit
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question