File uploat from a form – Project planner

Home Forums Shard – HTML5 Template File uploat from a form – Project planner

This topic contains 13 replies, has 2 voices, and was last updated by  ab-themes 8 years, 2 months ago.

Viewing 10 posts - 1 through 10 (of 14 total)
  • Author
    Posts
  • #13947

    piki007
    Participant

    Hello

    I want to use file upload in form (in demo: http://preview.magnior.com/?product=shard_html).

    Everything goes but files that I browse for are not attached in e-mail.
    Do I have to set somwhere wich filetypes are alowed ?
    Please if you can point me if I have to enable somethinf for attached files to work ?

    Regards, Matjaz

    #13951

    ab-themes
    Keymaster

    Hi Matjaz,

    you need to create contact form with upload button “Choose file”.

    When you create form please click on button “file” (look in attachment first picture)

    and result should be second picture.

    Sometimes clients sending too big files so we recommend you to zip files.

    We suggest you to read this for more:
    http://contactform7.com/file-uploading-and-attachment/

    I hope this help you.

    Cheers

    #13958

    piki007
    Participant

    Zdravo

    hehe. Najprej to je html predloga in ne wordpress. Tako da tista prva slika odpade.
    Druga slika, pa browse gumb je seveda v formi v bistvu je kar identična tisti v demotu. Texti iz polj pridejo na e-mail tako da je konfiguracija e-poste tudi ok. Ni pa priložene datoteke.

    Pošiljanje se odvije skozi /php/sendmail.php

    tukaj je zgornji del, kaj imam v sendmail.php (samo konfiguracija smtp je se spodaj):

    <?php

    $message_array = array();

    if(isset($_POST[‘formid’]) && $_POST[‘formid’]==’planner’){
    $subject = “Quote Request via Project Planner”;

    if(empty($_POST[‘name’])) $message_array[] = ‘Name’;
    if(empty($_POST[’email’])) $message_array[] = ‘Email’;
    if(empty($_POST[‘project-details’])) $message_array[] = ‘Project Details’;
    $body = ‘Name: ‘.$_POST[‘name’].'<br>’;
    $body .= ‘Email: ‘.$_POST[’email’].'<br>’;
    $body .= ‘Phone: ‘.$_POST[‘phone’].'<br>’;
    $body .= ‘project-details: ‘.$_POST[‘project-details’].'<br>’;
    // $body .= ‘file-attachment: ‘.$_POST[‘file-attachment’].'<br>’;
    // $body .= ‘project-type: ‘.$_POST[‘project-type’].'<br>’;
    $body .= ‘start-date: ‘.$_POST[‘start-date’].'<br>’;
    $body .= ‘due-date: ‘.$_POST[‘due-date’].'<br>’;
    $body .= ‘budget: ‘.$_POST[‘budget’].'<br>’;
    }
    else{
    $subject = “VLC2 Contact form”;

    if(empty($_POST[‘name’])) $message_array[] = ‘Name’;
    if(empty($_POST[’email’])) $message_array[] = ‘Email’;
    if(empty($_POST[‘subject’])) $message_array[] = ‘Subject’;
    if(empty($_POST[‘message’])) $message_array[] = ‘Message’;
    $body = ‘Name: ‘.$_POST[‘name’].'<br>’;
    $body .= ‘Email: ‘.$_POST[’email’].'<br>’;
    $body .= ‘Subject: ‘.$_POST[‘subject’].'<br>’;
    $body .= ‘Message: ‘.$_POST[‘message’].'<br>’;
    }

    if(sizeof($message_array)==1){
    $message = $message_array[0].’ is required field.’;
    }
    elseif(sizeof($message_array)>1){
    $message = join(‘ and ‘, array_filter(array_merge(array(join(‘, ‘, array_slice($message_array, 0, -1))), array_slice($message_array, -1)))). ‘ are required fields.’;
    // $message = implode(‘, ‘, $message_array). ‘ are required fields.’;
    }
    else{
    $message = ”;
    }

    if($message==” && (isset($_POST[‘action’]) && $_POST[‘action’]==’js’)){
    require_once(‘class.phpmailer.php’);
    include(“class.smtp.php”);

    #13980

    ab-themes
    Keymaster

    Hi,

    sorry, all the time I was thinking that this is WP Shard theme, but this is Shard HTML, my mistake.

    In the attachment I send you 2 files, please replace them with old ones.

    Cheers

    #14023

    piki007
    Participant

    This does not work either.

    #14073

    ab-themes
    Keymaster

    Hi,

    please send us your FTP credentials so we can fix this problem.

    Thank you

    Cheers

    #14154

    piki007
    Participant

    URL to contact form:
    http://www.commaserver.com/abthemes/contact.php

    #14167

    ab-themes
    Keymaster

    Hi,

    we updated your files. Now PHPMailer is set up the right way so it should work just fine.

    Kind regards

    #14172

    piki007
    Participant

    IT DOES NO WORK! In the file sendmail.php you have gmail acess as well. So enter data to the form and go see the email.
    In your form there is nothnig on email it does not even send.

    #14184

    ab-themes
    Keymaster

    Hi,

    email has not been sending because you had some javascript errors caused by not uploaded all js files. I have saved all your js files to BACKUP folder inside js folder in case you have made some customization and you need it.

    Further to send attachments via ajax form it is needed to use other methods.

    We have made all this customization for you, tested it on your email and now it works.

    Just for future reference if someone else will want to do this here is the code:

    in contact.php file, form header needs to be changed to:

    <form action="php/sendmail.php" method="post" class="contact-form" id="contact-form" enctype="multipart/form-data">

    also input field needs to be added:

    <input type="file" name="uploaded_file" size="40" class="contact-text">

    in sendmail.php file this needs to be added right before line with send() (@67 at current version)

    if (isset($_FILES['uploaded_file']) && $_FILES['uploaded_file']['error'] == UPLOAD_ERR_OK) {
       $mail->AddAttachment($_FILES['uploaded_file']['tmp_name'], $_FILES['uploaded_file']['name']);
    }

    and finally in custom.js change submitting part to:

            var myForm = document.querySelector('#contact-form');
            var formData = new FormData(myForm);
            formData.append('action', 'js');
    
            $.ajax({
                type: "POST",
                url: 'php/sendmail.php',
                data: formData,
                contentType: false,
                cache: false,
                processData:false,
                success: function(msg){
    

    Cheers :)

Viewing 10 posts - 1 through 10 (of 14 total)

The topic ‘File uploat from a form – Project planner’ is closed to new replies.