40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
|
--JS
|
||
|
var sv;
|
||
|
var subView = {
|
||
|
title : 'PengenPulang - Binusmaya',
|
||
|
require : 'PengenPulang',
|
||
|
rel : 'wrapper',
|
||
|
onLoaded : function(){
|
||
|
window.document.title = this.title;
|
||
|
sv = this;
|
||
|
$(".alert").hide();
|
||
|
$('#photoInput').on('change',function(){
|
||
|
var form_data = new FormData();
|
||
|
var file_date = $('#photoInput').prop('files')[0];
|
||
|
form_data.append('file',file_date);
|
||
|
BM.ajax({
|
||
|
url : mv.urlController + 'training/uploadFile',
|
||
|
type : 'POST',
|
||
|
data : form_data,
|
||
|
method : 'POST',
|
||
|
processData: false,
|
||
|
contentType: false,
|
||
|
success: function(data){
|
||
|
$('#textPhotoInput').val(data);
|
||
|
}
|
||
|
});
|
||
|
})
|
||
|
},
|
||
|
};
|
||
|
|
||
|
--PHP
|
||
|
public function uploadFile(){
|
||
|
if(!file_exists('storage')) mkdir('storage');
|
||
|
foreach($_FILES as $file){
|
||
|
file_put_contents('storage/'.$file["name"], fopen($file["tmp_name"],"r"));
|
||
|
$filename = $file["name"];
|
||
|
}
|
||
|
return $this->load->view('json_view', array('json' => $filename));
|
||
|
}
|
||
|
|