$thesis->comment_on_field = $_POST['proposed_field_brief']; $thesis->applicant_id = $session->applicant_id; $thesis->thesis_topic = $_POST['proposed_thesis_topic']; $thesis->proposal_on_thesis = $_POST['thesis_proposal']; $initiafilename = $_FILES['attach_thesis_proposal']['name']; $thesis_details = $thesis->find_by_id($session->applicant_id); if (!empty($thesis_details)) { $thesis->thesis_id = $thesis_details->thesis_id; } if ($thesis->save()) { if (!empty($_FILES['attach_thesis_proposal'])) { $files = new Files(); //$file_details = $files->find_by_id($session->applicant_id); /*find file record for proposed thesis*/ $sql_thesis_upload_file = "SELECT * FROM files WHERE applicant_id=" . $session->applicant_id . " AND caption='Thesis Proposal'"; $result_thesis_upload_file = Files::find_by_sql($sql_thesis_upload_file); foreach ($result_thesis_upload_file as $row) { $thesis_file_id = $row->file_id; $thesis_filename = $row->filename; } $files->upload_dir = "documents" . DS . "thesis"; if (!empty($thesis_file_id) && !empty($_FILES['attach_thesis_proposal']['name'])) { $files->file_id = $thesis_file_id; unlink(SITE_ROOT . DS . "documents" . DS . "thesis" . DS . $thesis_filename); } $arrayfiledetails = explode('.', $_FILES['attach_thesis_proposal']['name']); $extension = $arrayfiledetails[sizeof($arrayfiledetails) - 1]; $_FILES['attach_thesis_proposal']['name'] = $session->applicant_id . '-thesis.' . $extension; if ($files->attach_file($_FILES['attach_thesis_proposal'])) { $files->caption = 'Thesis Proposal'; $files->applicant_id = $session->applicant_id;
<?php //$thesis_details = Thesis::find_by_id($session->applicant_id); $db_upload_files = new MySQLDatabase(); $session = new Session(); /*find file record for degree certificate*/ $sql_deg_upload_file = "SELECT * FROM files WHERE applicant_id=" . $session->applicant_id; $result_deg_upload_file = Files::find_by_sql($sql_deg_upload_file); ?> <h3 align="center">Upload Relevant Documents</h3> <hr> <form action="" method="POST" class="uploadfiles form-horizontal" id="uploadfiles" > <br ><br > <input type="hidden" value="2097152" name="MAX_FILE_SIZE" /> <div class="row-fluid"> <div class="span7 offset2"> <div class="control-group"> <div class="controls"> <h4>Note:</h4> <p>The following documents are compulsory</p> <ul> <li>First degree certificate</li> <li>NYSC discharge certificate</li> </ul> </div> </div> <div id="upload_docs">
<input type="hidden" name="aid" value="' . customEncrypt($applicant_id) . '" /> </form> </tr>'; $index++; } echo '</tbody> </table>'; } } ?> <h4 align="center" class="alert alert-success">Attached Documents</h4> <?php $files = Files::find_by_sql("SELECT * FROM files WHERE applicant_id='" . $applicant_id . "'"); if (empty($files)) { echo 'Not Attached'; } else { echo ' <table class="table table-bordered table-hover"> <thead> <th>S/N</th> <th>File</th> <th>Type</th> <th>Size</th> </thead>'; $index = 1; echo '<tbody>'; foreach ($files as $file) { //$file = split("-", $file->filename);
<?php require_once '../inc/initialize.php'; $document_upload_msg = 0; $empty_file_msg = 0; $counter = 1; $max = 5; $upload_dir = "documents" . DS . "files"; foreach ($_FILES as $key => $value) { if (!empty($value) && $value["size"] != 0) { $sql = "SELECT * FROM files WHERE applicant_id=" . $session->applicant_id . " AND caption='Document " . $counter . "'"; $result = Files::find_by_sql($sql); $result = array_shift($result); $document = new Files(); $document->upload_dir = $upload_dir; if (!empty($result->file_id) && !empty($value['name'])) { $document->file_id = $result->file_id; unlink(SITE_ROOT . DS . $document->upload_dir . DS . $result->filename); } $filedetails = explode('.', $value['name']); $extension = $filedetails[sizeof($filedetails) - 1]; $value['name'] = $session->applicant_id . '-Document-' . $counter . '.' . $extension; if ($document->attach_file($value)) { $document->caption = 'Document ' . $counter; $document->applicant_id = $session->applicant_id; if ($document->save()) { $document_upload_msg = 1; } } else { sleep(2); echo "<table>";