|
使用uploadify或webuploader插件上传图片时候都提示You did not select a file to upload
controller如下
public function do_upload()
{
$config['upload_path'] = 'uploads';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 10000000;
$config['encrypt_name'] = 'true';
$this->load->library('upload', $config);
header('Content-Type: application/json; charset=utf-8');
header("HTTP/1.1 200 OK");
if ( ! $this->upload->do_upload('file_upload'))
{
$error = array('error' => $this->upload->display_errors());
echo json_encode(array('error'=> $error));
}
else
{
$data = array('upload_data' => $this->upload->data());
echo json_encode(array('data'=> $data));
}
}
网上提示 $this->upload->do_upload('file_upload') 与<input type="file" name="file_upload" id="file_upload">名称要一致
config/mimes.php 里'jpeg' => array('image/jpeg', 'image/pjpeg')要加上 'application/octet-stream'
加完均无效果,求教各位大大有没遇到此等问题,CI用的2.1 |
|