Codeigniter无法上传图像 [英] Codeigniter cannot upload image

查看:63
本文介绍了Codeigniter无法上传图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了2-3个小时,查看与此相关的每个stackoverflow线程。据我所知,很多人都感到沮丧。与许多其他图像一样,即使图像没有显示错误,我也无法上传图像。

I've been googling around for 2-3 hours looking at every stackoverflow thread related to this. As far as I can see, lots of people share my frustration. Like many others, I cannot upload an image, even though it shows no errors.

我已经尝试了所有在网上找到的所有内容,但似乎没有任何效果。 ..

I've literally tried anything and everything I found online, but nothing seems to work...

我只能使用var_dump($ _ FILES)查看图像的属性。我想将图像存储到文件夹中,并将其名称存储到数据库中。

I can only see the properties of the image with var_dump($_FILES). I want to store the image into a folder and its name into a database.

Controller

function upload_sl()
{ 
    $config['upload_path'] = 'sliki/samurajsliki/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size'] = '10000';

$this->load->library('upload', $config);
/*$this->upload->initialize($config);*/
/*var_dump($_FILES);*/
if ( ! $this->upload->do_upload())
{
  $error = array('error' => $this->upload->display_errors());

  $this->load->view('samuraj/slikaclen', $error);
}
else
{
  $data = array('upload_data' => $this->upload->data());

  $this->load->view('header_samurajmain');
  $this->load->view('samuraj/admin_samuraj');
  $this->load->view('footer_subpage');
}
}

查看

<?php echo $error;?>
                   <div class="center-block" style="width: 30%; height: 50%; clear:both;">
                   <?php echo form_open_multipart('admin_page/upload_sl');?>
                    <input type="file" name="userfile" size="20" />

                    <br />

                    <input type="submit" value="Стави нова слика" />
                    </form>
                     </div>


推荐答案

使用库Codeigniter(库上传单个文件和多个文件)轻松上传。

Using the library Codeigniter ( library upload single file and multi file ) Easily upload .

这篇关于Codeigniter无法上传图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆