Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 图像插入不起作用_Php_Image_Codeigniter - Fatal编程技术网

Php 图像插入不起作用

Php 图像插入不起作用,php,image,codeigniter,Php,Image,Codeigniter,当我插入图像时,它显示错误 无效偏移量 这是我的控制器 我已经从我的项目的另一个页面复制了它,它正在那里工作——但是在新页面上它显示了错误 $config['upload_path'] = './assets/upload/'; /* NB! create this dir! */ $config['allowed_types'] = 'gif|jpg|png|bmp|jpeg'; $config['max_size'] = '2048'; $config['max_width

当我插入图像时,它显示错误

无效偏移量

这是我的控制器

我已经从我的项目的另一个页面复制了它,它正在那里工作——但是在新页面上它显示了错误

  $config['upload_path'] = './assets/upload/'; /* NB! create this dir! */
  $config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
  $config['max_size']  = '2048';
  $config['max_width']  = '5000';
  $config['max_height']  = '5000';
  /* Load the upload library */
  $this->load->library('upload', $config);

  /* Create the config for image library */
  /* (pretty self-explanatory) */
  $configThumb = array();
  $configThumb['image_library'] = 'gd2';
  $configThumb['source_image'] = '';
  $configThumb['create_thumb'] = TRUE;
  $configThumb['maintain_ratio'] = TRUE;
  /* Set the height and width or thumbs */
  /* Do not worry - CI is pretty smart in resizing */
  /* It will create the largest thumb that can fit in those dimensions */
  /* Thumbs will be saved in same upload dir but with a _thumb suffix */
  /* e.g. 'image.jpg' thumb would be called 'image_thumb.jpg' */
  $configThumb['width'] = 140;
  $configThumb['height'] = 210;
  /* Load the image library */
  $this->load->library('image_lib');
$file=array();
$file_thumb=array();
             /* We have 5 files to upload
   * If you want more - change the 6 below as needed
   */
  for($i = 1; $i < 3; $i++) {
    /* Handle the file upload */
    $upload = $this->upload->do_upload('image'.$i);
    /* File failed to upload - continue */
    if($upload === FALSE) continue;
    /* Get the data about the file */
    $data = $this->upload->data();
    $file[$i] = $data['file_name'];
    $file_thumb[$i] = $data['raw_name'].'_thumb'.$data['file_ext'];


    $uploadedFiles[$i] = $data;
    /* If the file is an image - create a thumbnail */
    if($data['is_image'] == 1) {
      $configThumb['source_image'] = $data['full_path'];
      $this->image_lib->initialize($configThumb);
      $this->image_lib->resize();
    }
  }

///=============upload end here==================////
    echo $file['1'];
    exit;
$config['upload_path']='。/assets/upload/';/*注意!创建这个目录*/
$config['allowed_types']='gif | jpg | png | bmp | jpeg';
$config['max_size']='2048';
$config['max_width']='5000';
$config['max_height']='5000';
/*加载上载库*/
$this->load->library('upload',$config);
/*创建映像库的配置*/
/*(不言自明)*/
$configThumb=array();
$configThumb['image_library']='gd2';
$configThumb['source_image']='';
$configThumb['create_thumb']=TRUE;
$configThumb['Maintent_ratio']=TRUE;
/*设置拇指的高度和宽度*/
/*不用担心-CI在调整大小方面非常聪明*/
/*它将创建最大的拇指,可以适应这些尺寸*/
/*拇指将保存在同一上传目录中,但带有_拇指后缀*/
/*例如,“image.jpg”拇指将被称为“image_thumb.jpg”*/
$configThumb['width']=140;
$configThumb['height']=210;
/*加载图像库*/
$this->load->lib('image_lib');
$file=array();
$file_thumb=array();
/*我们有5个文件要上传
*如果您想要更多,请根据需要更改下面的6
*/
对于($i=1;$i<3;$i++){
/*处理文件上传*/
$upload=$this->upload->do_upload('image'.$i);
/*文件上载失败-继续*/
如果($upload==FALSE)继续;
/*获取有关该文件的数据*/
$data=$this->upload->data();
$file[$i]=$data['file_name'];
$file_thumb[$i]=$data['raw_name']。“u thumb'.$data['file_ext'];
$uploadedFiles[$i]=$data;
/*如果文件是图像-创建缩略图*/
如果($data['is_image']==1){
$configThumb['source_image']=$data['full_path'];
$this->image\u lib->initialize($configThumb);
$this->image_lib->resize();
}
}
///================上传到此结束==================////
echo$file['1'];
出口

您已经设置了一些图像拇指

$configThumb = array();
$configThumb['image_library'] = 'gd2';
$configThumb['source_image'] = '';
$configThumb['create_thumb'] = TRUE;
$configThumb['maintain_ratio'] = TRUE;
$configThumb['width'] = 140;
$configThumb['height'] = 210;
好的。您还可以加载库
$this->load->library('image_lib')

那么,这些设置是如何将config设置到库的


再加上这个

$this->load->library('image_lib', $configThumb); # configuration variable

读这个


发布完整的错误消息,包括您的表格!!遇到PHP错误严重性:注意消息:未定义的偏移量:1文件名:controllers/biaso.PHP行号:105 Bias Pic:No需要
for loop
,因为您只需上传一个文件。如果我的回答有帮助,请阅读此链接,感谢您接受。非常感谢。