Download file after submit

Home Forums Quform WordPress Download file after submit

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 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 years, 2 months ago by Ally.
    #33997
    oivanr
    Participant

    Hi Ally,
    I didn’t work on this until now. That’s why I didn’t tell you the advance.
    Your solution redirecting the page is very good, it download the file, the problem now is that the form don´t finish the process (send you the image of the rounding circle working).
    What I mean the form is not finishin is
    a) Confirmation-> redirect to a custom URL: the file is dowloaded but the form keeps the information and don´t let to intoduce new information, The circle keeps rounding.
    b) Confirmation-> display a message and redirect to a custom URL: the file is downloaded, a message is displayed but don’t clear the fields and don’t let to introduce new information.
    I can’t give you access to the form because I am working in a local host previous to up the form to my website.
    What do you think is happenning?
    Thanks in advance.

    Attachments:
    You must be logged in to view attached files.
    #34005
    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.

    #34064
    oivanr
    Participant

    Hi @Ally
    I did what you sad and I worked fine. You can close this issue.
    Now I will ask in another topic about js and popup forms with elementor.
    Thanks a lot,

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