在这段代码中,我有一个名为proposal.php的控制器,我希望当我上传文件onclick按钮时,它会使目录和上传的文件保存在其中。现在,目录已成功创建,但文件未在其中上传。那么,我该如何解决这个问题呢?请帮帮我。
controller:proposal.php
public function upload_file_folder()
{
$folder_name = $this->input->post('account_name');
mkdir('resource/proposal_data/'.$folder_name.'_proposal_'.date('Y-m-d').'',0777, true);
$filename = $_FILES[$this->input->post('file1')]['name'];
$path = FCPATH."resource/proposal_data/".$folder_name."_proposal_".date('Y-m-d')."";
$move=move_uploaded_file($_FILES[$this->input->post('file1')]['tmp_name'],$path.$_FILES[$this->input->post('file1')]['name']);
echo "upload";
}
视图:
<script>
$(document).ready(function(){
$("#mk").bind("click",function(){
file1 = $("#file1").val();
account_name = $("#account_name").val();
$.ajax({
type:"POST",
data:{"file1":file1, "account_name":account_name},
url:"<?php echo base_url('index.php/'); ?>purposal/upload_file_folder",
success:function(data){
alert(data);
}
});
});
});
</script>
<input type="file" name="file1" id="file1">
<button type="submit" name="mk" id="mk">upload</button>
谢谢
答案 0 :(得分:0)
你可以试试这个:
easing