sam13579 Posted May 8, 2022 Posted May 8, 2022 This is the code $thanks = ""; $tempDir = $config->paths->assets . "files/applications/"; if ($input->post('title')) { print_r($input->get('doc')); $p = new Page(); $p->template = 'Application'; //or whatever your template is called $p->parent = wire('pages')->get('/applications/'); //or whatever the parent page is called $p->application_title = $input->post->text('title'); $p->application_first_name = $input->post->text('fname'); $p->application_middle_name = $input->post->text('mname'); $p->application_last_name = $input->post->text('lname'); $p->application_position = $input->post->text('position'); echo "<script>window.alert('".$input->post('doc')."');</script>"; $p->application_email = $input->post->email('email'); $p->application_reference_no = $input->post->text('ref_no'); $p->application_telephone_no= $input->post->text('tel_no'); $p->application_date= $input->post->text('date'); $p->save(); $files = explode("|",$input->get('doc')->value); foreach($files as $file){ if($file && file_exists($tempDir . $file)){ $p->application_document->add($tempDir . $file); print_r($p); } } $p->save(); } ?> And the html part is : <form action='' method='post' enctype="multipart/form-data"> <div class=''> <label for='title'>Title</label> <select name='title' id='title'> <option value='Mr.'>Mr.</option> <option value='Ms.'>Ms.</option> </select> </div> <div class=''> <label for='fname'>First Name</label> <input id='fname' type='text' name='fname' /> </div> <div class=''> <label for='mname'>Middle Name</label> <input id='mname' type='text' name='mname' /> </div> <div class=''> <label for='lname'>Last Name</label> <input id='lname' type='text' name='lname' /> </div> <div class=''> <label for='position'>Position</label> <input id='position' type='text' name='position' /> </div> <div class=''> <label for='ref_no'>Reference No.</label> <input id='ref_no' type='text' name='ref_no' /> </div> <div class=''> <label for='email'>E-mail</label> <input id='email' type='email' name='email' /> </div> <div class=''> <label for='tel_no'>Telephone No.</label> <input id='tel_no' type='text' name='tel_no' /> </div> <div class=''> <label for='document'>Document(PDF)</label> <input id='document' type='file' name='doc' /> </div> <div class=''> <label for='date'>Date</label> <input id='date' type='date' name='date' /> </div> <button type='submit' class="btn btn-bronze-outline rounded-pill">Apply Now</button> </form> Evrything is stored except for the file. What might be wrong here?
sam13579 Posted May 8, 2022 Author Posted May 8, 2022 @ryan it would be really helpful if you could help me with it. Thanks is advance.
Jan Romero Posted May 8, 2022 Posted May 8, 2022 Hi. You're using $input->get('doc') in a couple of places, but the files are sent in a POST request. Also, check out this thread, especially the bit about "new WireUpload()": Additionally please note how the code blocks are formatted in that thread. Please do the same when posting lengthy code excerpts. You can click the button labelled "<>" above the text editor to insert a code block and even choose the programming language there.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now