Download file after submit

Home Forums Quform WordPress Download file after submit

This topic is: not resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #33866
    oivanr
    Participant

    Hi,
    I am working in a form that get basic user information, record it in a table and after must download an apk file.
    I already record the information

    global $wpdb;
    $current_user = wp_get_current_user();
    $usuarioLogin = $current_user->user_login;
    $dbTable = ‘wp_pilas_estudiantes’;
    $fechaHoy = date(‘Y-m-d’);
    $fechaVenc = time() + (5 * 24 * 60 * 60); // 5 días por 24 horas * 60 minutos * 60 segundos

    $camposAfectados = [‘stdnt_codPais’ => $form->getValue(‘quform_38_14′),’stdnt_telefono’ => $form->getValue(‘quform_38_18’), ‘stdnt_usuario’ => $form->getValue(‘quform_38_3’),
    ‘stdnt_nombres’ => $form->getValue(‘quform_38_26’), ‘stdnt_apellidos’ => $form->getValue(‘quform_38_27’), ‘stdnt_licGrado’ => $form->getValue(‘quform_38_39’),
    ‘stdnt_clg_ID’ => $form->getValue(‘quform_38_69’), ‘stdnt_secc_ID’ => $form->getValue(‘quform_38_70’), ‘stdnt_registro’ => $form->getValue(‘quform_38_71’),
    ‘stdnt_licencia’ => $form->getValue(‘quform_38_72’), ‘stdnt_lic_venc’=>date(‘Y-m-d’,$fechaVenc), ‘usuario’=> $usuarioLogin];
    $wpdb->insert($dbTable, $camposAfectados);

    But when I try to dowload the file true php is doesn’t work, because it keeps open the file and don’t download anything, just like it starts to dowloand but never ends.

    $file = ‘http://127.0.0.1/pilas/wp-content/uploads/2022/01/pilas.apk’;
    header(‘Content-Description: File Transfer’);
    header(‘Content-Type: application/apk’);
    header(‘Content-Disposition: attachment; filename=’.basename($file));
    header(‘Content-Transfer-Encoding: binary’);
    header(‘Expires: 0’);
    header(‘Cache-Control: must-revalidate, post-check=0, pre-check=0’);
    header(‘Pragma: public’);
    header(‘Content-Length: ‘ . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;

    Can you help me please.
    Thanks in advance

    #33868
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    • This reply was modified 2 weeks, 5 days ago by Ally.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2020 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy