我已完成文件上传但如果文件名为" 213134.jpg"但我的代码存储数据库只有名称" 213134"没有文件类型。你能帮我么。我已经使用CI来完成这项任务
function postMessage(){
$config['upload_path'] = './uploads/inbox/';
$config['allowed_types'] = 'jpg';
$config['max_size'] = '2048';
$config['max_width'] = '3000';
$config['max_height'] = '3000';
$random=rand(00000, 99999);
$id=$this->session->userdata('id');
$pic=$id*$random;
$config['file_name'] =$pic;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
}
else
{
$blog_msg ='Sorry, Picture uploaded.';
}
$u_id=$this->session->userdata('id');
$u_name=$this->session->userdata('u_fname');
$to=$this->uri->segment(3);
$date= $date=date('d-M-Y');
$message=$_POST["message"];
$data=array(
'm_from'=>$u_id,
'from_name'=>$u_name,
'm_date'=>$date,
'm_body'=>$message,
'm_to'=>$to,
'm_attach'=>$pic
);
}
答案 0 :(得分:2)
<p><span class="name">Jean</span> was a little girl, and she liked <span class="special">programming</span> very much.</p>
<p>One day, <span class="name">Jean</span> went to <span class="name">Annie</span>'s house and saw a very surprising work <span class="name">Annie</span> had done, by accident.</p>
<p><span class="name">Annie</span> then let <span class="name">Jean</span> join her secret work...</p>
方法01
$config['allowed_types'] = 'jpg|jpeg';//Change this
方法02
或者你可以尝试
$data=array(
'm_from'=>$u_id,
'from_name'=>$u_name,
'm_date'=>$date,
'm_body'=>$message,
'm_to'=>$to,
'm_attach'=>$this->input->post('pic'), //change this(in your HTML attribute name='' )
);