?
Current Path : /home1/savoy/public_html/savoyglobal.net/eldertree/application/views/master/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/eldertree/application/views/master/upload_form.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?> <style> .controls { width: 195px; } .form-actions { padding: 10px; } </style> <span class="section_content_top"></span> <div class="row-fluid"> <div class="tab-pane " id="tab_2"> <div class="portlet box yellow" style="margin: 0;border: 2px solid #b4cef8;"> <div class="portlet-title"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin: 5px 0 0 0;"></button> <div class="caption"><i class="icon-reorder"></i>Upload File</div> <div class="tools"> <!-- <a href="#" onclick="viewdata('master','viewinmastersearch','search_policy_type','view_policy_type','1');" class="remove"></a>--> </div> </div> <div class="portlet-body form"> <?php $file = $this->mastermodel->getdatas('file_type', 'file_type_id'); $attributes = array('id' => 'validateform', 'class' => 'form-horizontal validate'); echo form_open_multipart('master/submit_upload/' . $upload_function, $attributes); ?> <input type="hidden" name="master_id" value="<?= $file_record_id; ?>"/> <input type="hidden" name="return_page" value="<?= $return_page; ?>"/> <h3 class="form-section"></h3> <div class="row-fluid"> <div class="span6 "> <div class="control-group"> <label class="control-label">File Name</label> <div class="controls"> <select name="file_type_id" class="required chosen" id="file_type_id" "> <option value="">--Select--</option> <?php foreach ($file as $list) { ?> <option value="<?= $list['file_type_id'] ?>"><?= $list['file_type'] ?> </option> <?php } ?> </select> </div> </div> </div> </div> <div class="row-fluid"> <div class="span6 "> <div class="control-group"> <label class="control-label">Choose File</label> <div class="controls"> <input class="text required span12" name="upload_file" id="upload_file" type="file" style="line-height: 20px;width: 195px" /> </div> </div> </div> </div> <div class="form-actions"> <button type="submit" class="clickimage btn blue" onclick="addformdata1('validateform')" ><i class="icon-ok"></i>Save</button> </div> <?php echo form_close(); ?> <!-- END FORM--> </div> </div> </div> </div> <script> var files; $(document).ready(function(){ $('form').on('submit', uploadFiles); }); $('input[type=file]').on('change', function(){ files = event.target.files; }); function uploadFiles(event) { event.stopPropagation(); event.preventDefault(); var data = new FormData(); $.each(files, function(key, value) { data.append(key, value); }); var frmData = $(event.target).serializeArray(); $.each(frmData, function(key, field) { data.append(field.name, field.value); }); $modal = $('#ajax-modal'); $.ajax({ url: '<?= site_url("master/submit_upload/upload_file?files") ?>', type: 'POST', data: data, cache: false, dataType: 'json', processData: false, contentType: false, success: function(data) { alert(data.json_msg); $modal.modal('toggle'); }, error: function(jqXHR, textStatus, errorThrown) { console.log('ERRORS: ' + textStatus); } }); } function submitForm(event, data) { $form = $(event.target); var formData = $form.serialize(); $.each(data.files, function(key, value) { formData = formData + '&filenames[]=' + value; }); $.ajax({ url: 'submit.php', type: 'POST', data: formData, cache: false, dataType: 'json', success: function(data, textStatus, jqXHR) { if(typeof data.error === 'undefined') { console.log('SUCCESS: ' + data.success); } else { console.log('ERRORS: ' + data.error); } }, error: function(jqXHR, textStatus, errorThrown) { console.log('ERRORS: ' + textStatus); }, complete: function() { } }); } </script>