Image Can';t在Codeigniter中上载图像
我在Codeigniter中上载图像时遇到问题,当我添加新图像时出现错误显示(您没有选择要上载的文件)。我不知道我的代码中是否遗漏了某些内容 这是我的功能控制器:Image Can';t在Codeigniter中上载图像,image,file,upload,codeigniter-3,Image,File,Upload,Codeigniter 3,我在Codeigniter中上载图像时遇到问题,当我添加新图像时出现错误显示(您没有选择要上载的文件)。我不知道我的代码中是否遗漏了某些内容 这是我的功能控制器: public function upload_img(){ $this->load->model('esthetique_model'); $config['upload_path'] = realpath(APPPATH.'../upload'); $config['al
public function upload_img(){
$this->load->model('esthetique_model');
$config['upload_path'] = realpath(APPPATH.'../upload');
$config['allowed_types'] = 'jpg|jpeg|png|gif';
$config['max_size'] = '204800';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload()){
$error = array('error' => $this->upload->display_errors());
foreach ($error as $item => $value){
echo'<ol class="alert alert-danger"><li>'.$value.'</ol></li>';
}
exit;
}else{
$upload_data = $this->upload->data();
$path = $upload_data['file_name'];
$this->esthetique_model->photo_insert_mdl($path);
echo'<h4 style="color:green">Image uploaded Succesfully</h4>';
}
}
...
if ( ! $this->upload->do_upload('userfile')) {
...
public函数上传\u img(){
$this->load->model('esthetique_model');
$config['upload_path']=realpath(APPPATH.../upload');
$config['allowed_types']='jpg | jpeg | png | gif';
$config['max_size']='204800';
$this->load->library('upload',$config);
如果(!$this->upload->do_upload()){
$error=array('error'=>$this->upload->display_errors());
foreach($item=>$value时出错){
回显“”.$value.“ ”;
}
出口
}否则{
$upload_data=$this->upload->data();
$path=$upload_data['file_name'];
$this->esthetique\u model->photo\u insert\u mdl($path);
echo“图像上传成功”;
}
}
我的看法是:
<?php echo form_open('esthetique/upload_img'); ?>
<div class="modal-body">
<!-- hidden input montinned with class sr-only -->
<div class="form-group"><label class="sr-only" =""></label>
<input type="text" name="idsc" class="sr-only" id="idsc" ></div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="userfile">Choisissez l'image</label>
<input type="file" name="userfile" id="userfile">
</div>
</div>
<div class="form-group">
<img id="loader" src="<?php echo base_url() ?>asset/images/486.GIF" style="height: 30px;">
</div>
<div class="form-group">
<img id="preview" src="#" style="height: 80px;border: 1px solid #DDC; " />
</div>
</div>
<div class="form-group ">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar">
</i>
</div>
<input class="form-control" id="date" name="date" placeholder="Date" type="text"/>
</div>
</div>
<div class="form-group">
<textarea class="form-control" row="3" id="note" name="note" placeholder="Note"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
<button type="submit" class="btn btn-primary">Enregistrer</button>
</div>
<?php echo form_close(); ?>
</div>
</div>
</div>
选择塞兹图像
asset/images/486.GIF“style=“height:30px;">
费尔默
登记员
感谢您的帮助尝试以下操作(在控制器中指定文件输入名称):
更多有用的信息:尝试以下操作(在控制器中指定文件输入名称):
更多有用的信息:我已在视图中更改
<?php echo form_open('esthetique/upload_img'); ?>
借
它现在的工作我已经改变了看法
<?php echo form_open('esthetique/upload_img'); ?>
借
它现在可以工作了谢谢@Nic的回答,我已经指定了输入名称,但是出现了一些错误谢谢@Nic的回答,我已经指定了输入名称,但是出现了一些错误