php - codeigniter 保存图像的路径而不是 blob
问题描述
我找不到解决问题的好方法,所以我需要你的帮助。
我已经创建了控制器,但我认为缺少一些东西,所以我可以以适当的方式上传我的图像。
直到现在我可以上传,但是如果我尝试在网站上看到它们,我只能看到非常奇怪的字符,甚至数据库中的图像名称也很奇怪。
我的控制器:
public function do_upload(){
$config['upload_path'] = './assets/img/upload';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 512000;
$config['max_width'] = 2440;
$config['max_height'] = 1600;
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile')) {
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
} else {
$data = array('upload_data' => $this->upload->data());
$this->load->view('perfil');
}
}
和我的观点:
<?php echo form_open(base_url() . 'index.php/perfil/update/' . $perfil[0]->id_user); ?>
<?php echo form_open_multipart('perfil/do_upload');?>
<input type="file" name="imagem" size="9999" class="form-control" id="imagem">
<label class="texto">Email:</label>
<input type="email" name="email" value="<?php echo $perfil[0]->email; ?>" class="form-control outros">
<label class="texto">Nome:</label>
<input type="text" name="nome" value="<?php echo $perfil[0]->nome; ?>" class="form-control outros">
<label class="texto">Morada:</label>
<input type="text" name="morada" value="<?php echo $perfil[0]->contato; ?>" class="form-control outros">
<label class="texto">Contato:</label>
<input type="text" name="contato" value="<?php echo $perfil[0]->morada; ?>" class="form-control outros">
<label class="texto">Password:</label>
<input type="password" name="password" value="<?php echo $perfil[0]->password; ?>" class="form-control outros">
<br>
<div class="col-md-6 offset-md-3">
<button type="submit" class="btn btn-default btnadmin">Guardar</button><br><br>
我的模型:
function post($data){
$this->db->insert('utilizadores', $data);
}
解决方案
推荐阅读
- php - laravel carbon 无法显示默认促销
- c++ - 包含库文件但仍未定义引用
- mysql - mysqldump:无法执行。information_schema 中的未知表“column_statistics”
- html - 如何根据片段创建电话输入
- ios - iOS 密码自动填充附件视图使应用程序卡住
- c# - C# 的 StringInfo 和 TextElementEnumerator 无法正确识别字素
- react-native - Actions.replace(key) 在本机反应中不起作用,它给出错误,如错误所示
- java - 无法将“java.lang.String”类型的值转换为所需的模型对象类型
- typescript - 使用量角器、typepscript 和 jasmine 进行自动化测试
- c - c管道等待消息达到一定大小然后发送?