我需要完整的代码,在那里我可以上传数据库中的完整图像大小(不仅是图像路径,还有整个图像大小)。提前感谢
要上传图像或文件,请使用以下代码将其作为上传到控制器
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
Refferecne:Codeigniter文件上传指南
如果你想使用Ajax上传图像,请不要忘记敲门,然后我会给出整个代码块。
谢谢!
您是否试图将图像转换为字节并将其保存在MYSQL数据库中?如果是,那么尝试这个代码
<?php
$filename = "image.png";
$file = fopen($filename, "rb");
$contents = fread($file, filesize($filename));
fclose($file);
?>