图像插入在本地服务器上运行,但在实时服务器上不运行

时间:2015-12-26 05:10:07

标签: php image

图像插入不能在实时服务器上运行,但是当我在本地服务器上运行相同的代码时,它的工作正常。请告诉我该怎么做。它甚至没有在数据库中插入文件名。是路径问题还是其他什么?

这是我的控制者:

  $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();
    }
  }

上传到此结束。

1 个答案:

答案 0 :(得分:1)

实时服务器上的上传路径可能无法写入。