Codeigniter 3.1.0文件上传工作,但图像' full_path'信息从未插入数据库

时间:2016-10-24 17:25:52

标签: php mysql codeigniter

我设法拼凑了一个用户个人资料页面,该页面将所有当前/相关的users表格输出到表单文本输入中(通过set_value()),并且还有一个文件上传输入图像上传(更新时显示在页面上)。表单上传过程确实很简单;

Profile.php(控制器文件)

function update() //"action" method from submission form 
{
      if ($this->input->server('REQUEST_METHOD') == 'POST') 
      {
          $this->form_validation->set_rules('website', 'Website');
          $this->form_validation->set_rules('password', 'Password', 'trim|min_length[4]|max_length[32]');
          $this->form_validation->set_rules('avatar', 'Profile Image', 'callback_image_upload');

          $this->form_validation->set_message('min_length', 'This %s must have at least %s characters');
          $this->form_validation->set_message('max_length', 'This %s must have at least %s characters');

           if($this->form_validation->run() == TRUE)
           {
              //Get the info from the form
              $website = $this->input->post('website');
              $password = $this->input->post('password');
              $temp = $this->upload->data('full_path');
              $avatar = $temp['file_name']; // to get image file name from upload script to be stored in the database

              //load the model
              $this->load->model('profile_model');
              $this->Profile->updateProfile($id,$avatar,$website, $password);
           }
           else
           {
              redirect('profile', 'refresh');           
           }
     }
}

function image_upload() //callback for previous update function
{ 
  if($this->ion_auth->logged_in())
  {
  if($_FILES['avatar']['size'] != 0)
  {
     $id = $this->ion_auth->get_user_id('id');

     $config['upload_path']   = './assets/images/avatars/'; 
     $config['allowed_types'] = 'gif|jpg|jpeg|png'; 
     $config['file_name']     = 'avatar_'.substr(md5(rand()),0,7);
     $config['overwrite']     = true; 
     $config['max_size']  = 10400; 

     $this->load->library('upload', $config);
     $this->upload->initialize($config);

      if (!$this->upload->do_upload('avatar'))
      { 
         $error = array('error' => $this->upload->display_errors());
         $this->load->view('profile_view', $error);  
      }    
      else
      {
         $avatar = $this->upload->data();

         $data = array(
            'path' => $avatar['full_path'],
            'avatar' => $avatar['file_name'],
            'maintain_ratio' => true,
            'width' => 300,
            'height' => 300

         );
         $fname = $avatar['file_name'];
         $fpath=$avatar['full_path'].$fname;

         return $avatar;
      }    
  }    
 }
}

我知道一个事实,我开始在第二个函数结束时绊倒并崩溃,关于让$avatar['full_path'] CI数据数组原型元素插入到users上的db列中名为avatar的表。重写了前两个转录函数以及模型;

//function to update user_profile    
function updateProfile($id, $avatar, $website, $password)
{
  if($this->ion_auth->logged_in())
  {
    if($_FILES['avatar']['error'] == 0)
    {       
      $avatar = $this->input->post('avatar');
      $website = $this->input->post('website');
      $password = $this->input->post('password');

      $data = array(
          'avatar' => $this->input->post('avatar'),
          'website' => $this->input->post('website'),
          'password' => $this->input->post('password')             
      );
      $this->db->set('avatar', $avatar);
      $this->db->set('website', $website);
      $this->db->set('password', $password);
      $this->db->where('id', $id);
      $this->db->update('users', $data);
      redirect('profile', 'refresh');
      exit;       
    }
  }
}

我正在试图看到完全点破坏数据提交过程的眼睛疲劳。不使用$this->db->insert(),因为我需要允许用户更新其网站,密码和个人资料图片。充满了替换和插入的想法,以及本机的PHP方法;

if ($_FILES["file"]["error"] > 0)
{
   echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else
{
    echo "File: ".$_FILES["file"]["name"]." Uploaded in:".$_FILES["file"]["tmp_name"];
}

move_uploaded_file($_FILES['uploaded_file']['tmp_name'], 
$image_path. $_FILES['uploaded_file']['name']);
$full_image_path = '/images/'.$_FILES['uploaded_file']['name']; 
$sql="insert into table_name(image) values( '$full_image_path')";

但这是当本地传播不太理想的效果时的其中一次。我检查过的每一个与我相关的问题都让我质疑变量值来自/去往的地方,或者试图采用替代方法来牺牲已经实现的功能上传机制。奇怪的是,我甚至设法确定了一些我认为会更难的东西;

<div class="row">
      <!-- left column -->
      <div class="col-md-3">
        <div class="text-center">
        <?php
        if(isset($user->avatar)){ // if the avatar has been uploaded then display it ?>
        <img src="<?php echo base_url().'assets/images/avatars/'.$user->avatar; ?>" class="avatar img-circle" alt="Profile Image" width="300px">
        <?php } else { ?>
        <img src="<?php echo base_url().'assets/images/avatars/default.jpg'; ?>" class="avatar img-circle" alt="Profile Image" width="300px">                       
        <?php } ?>      
          <?php echo '<h3 class="text-info">'.$user->first_name.' '.$user->last_name.'</h3>.'; ?>
          <h6>Upload a different photo...</h6>
          <input id="avatar" name="avatar" type="file" class="form-control" /><br>
        </div>
      </div>

在没有新用户的用户头像的情况下,让个人资料图片显示default.jpg;

User Profile Edit Page

当然,如果我不能让用户改变那些(有限的)细节,那么配置文件编辑套件有什么用处(哈哈!)?大约9个小时后(同时),我觉得有必要再戴一双眼睛。

在线更新

甚至尝试使用upload image and insert text in codeigniter中设置的代码,因为看起来可能是回调搞砸了。我的结果是我能够更改文本输入(当我刷新PHPMyAdmin视图(?!?)时没有注册更改),但是我丢失了上传功能。花了最后45分钟尝试编码并同时发布(哈哈!)。在发布此内容后,将尝试热烈地整合这两种方法。 再次感谢能够看到我绊倒的人......

更新2:它变得陌生......

所以,我重新编写单个代码块(profile/update)并直接从Profiler检查CI PostData结果,我仍然没有任何表更新,尽管我和#39; m显示了这一点;
Current CI Profiler Output

即使Profiler输出指示上传的图像位于我的WAMP解决方案的tmp目录中,在那里浏览也会出现一个大而肥的鹅蛋(除非上传以某种方式损坏 - 不要尽管如此,看到任何证据。我的下一步行动是在realpath上抛出APPPATH$config['upload_path'](或两者的组合)只是为了看看是否会松动。至于文本输入,我还没有愿意触摸password,直到我看到其他元素都插入第一个。目前,仍在尝试计算如何将我的两个独立函数集成到单个代码块中。这是我在ATM上的高原......以及created_on列自动更新到当前日期时间的(微不足道的)问题,而不是用户实际创建时的问题。 Mayhap是我在该专栏中翻译Unix时间的方法的结果 - 但它在我尝试压扁的果酱旁边显得苍白无力。

有时,我尝试的更多......

我非常喜欢我之前提供的链接解决方案,我看到双红色的ATM(哈哈!)。为了解决这个问题,我已经经历了一系列的排列,我已经接受了一系列新问题。我不确定除了使用callback_image_upload链接提交流程之外的任何其他方案(特别是因为我现在感觉链接解决方案是用于CI 2.x安装)。它只是愚弄文档批准的编码;

$error = array('error' => $this->upload->display_errors());
$this->load->view('profile_view', $error);

     OR

$data['error'] = array('error' => $this->upload->display_errors());
$this->load->view('profile_view', $data);

    BOTH == 0  

这只是一个单调乏味的事情,排列的水平几乎没有成为一个严格的代码连枷版本;

function update() //solid code block - 1st attempt
{
   if($this->ion_auth->logged_in())
   {
      if ($this->input->server('REQUEST_METHOD') == 'POST') 
      {
          $this->load->library('form_validation');

          $this->form_validation->set_rules('website', 'Website', 'trim');
          $this->form_validation->set_rules('password', 'Password', 'trim|min_length[4]|max_length[32]');

          $this->form_validation->set_message('min_length', 'This %s must have at least %s characters');
          $this->form_validation->set_message('max_length', 'This %s must have at least %s characters');

           if($this->form_validation->run() == FALSE)
           {
              // failed validation? return to submit form page
              $this->load->view('profile_view');

              // quit here
              return false;
           }
           else
           {
              if($_FILES['avatar']['size'] != 0)
              {
                 $id = $this->ion_auth->get_user_id('id');
                 $config['upload_path']   = './assets/images/avatars/'; 
                 $config['allowed_types'] = 'gif|jpg|jpeg|png'; 
                 $config['file_name']     = 'avatar_'.substr(md5(rand()),0,7);
                 $config['overwrite']     = true; 
                 $config['max_size']  = 10400; 

                 $this->load->library('upload', $config);
                 $this->upload->initialize($config);            
              }
           }

           if ( ! $this->upload->do_upload('avatar'))
           {
              // no file uploaded or failed upload
              $error = array('error' => $this->upload->display_errors());
              $this->load->view('profile_view', $error);
           }
           else
           {
              // success
              $avatar = $this->upload->data('full_path');
              $website = $this->input->post('website');
              $password = $this->input->post('password');

              // a model that deals with your image data (you have to create this)
              $this->Profile->updateProfile($id, $website, $password, $avatar);
           }                 
      }

   }
}

===========================================================================  

function do_upload() //solid code block - 2nd attempt
{
  if($this->ion_auth->logged_in())
  {
     // validate the POST data
     $this->form_validation->set_rules('website', 'Website', 'trim');
     $this->form_validation->set_rules('password', 'Password', 'trim|min_length[4]|max_length[32]');

     $this->form_validation->set_message('min_length', 'This %s must have at least %s characters');
     $this->form_validation->set_message('max_length', 'This %s must have at least %s characters');

       if ($this->form_validation->run() == FALSE)
       {   
          // failed validation
          $this->load->view('profile_view');

          // quit here
          return false;
       }

       $config['upload_path']   = './assets/images/avatars/'; 
       $config['allowed_types'] = 'gif|jpg|jpeg|png'; 
       $config['file_name']     = 'avatar_'.substr(md5(rand()),0,7);
       $config['overwrite']     = true; 
       $config['max_size']  = 10400; 

       $this->load->library('upload', $config);
       $this->upload->initialize($config);

       if ( ! $this->upload->do_upload('avatar'))
       {
           // no file uploaded or failed upload
          $data['error'] = array('error' => $this->upload->display_errors());
          $this->load->view('profile_view', $data);
}
else
{
    // success
    $avatar = array('upload_data' => $this->upload->data());
    $website = $this->input->post('website');
    $password = $this->input->post('password');

    // a model that deals with your image data (you have to create this)
    $this->Profile->updateProfile($website, $password, $avatar['full_path']);

    $this->load->view('profile_view', $data);
}}}  

==========================================================================  

  // view
  echo form_open_multipart('update/do_upload');
  echo form_input('website', '');
  echo form_input('password', '');
  echo form_upload('avatar');
  echo form_close


   // controller
   function do_upload()
   {
  $config['upload_path'] = './uploads/';
  $config['allowed_types'] = 'gif|jpg|png';
  $config['max_size'] = '100';
  $config['max_width']  = '1024';
  $config['max_height']  = '768';

  $this->load->library('upload', $config);

  // validate the POST data
  $this->form_validation->set_rules('website', 'Website', 'trim|required');
  $this->form_validation->set_rules('password', 'Password', 'trim|required')

  if ($this->form_validation->run() == FALSE)
  {   
    // failed validation
    $this->load->view('profile_view');
    return false;
   }

   if ( ! $this->upload->do_upload('avatar'))
   {
    // no file uploaded or failed upload
    $error = array('error' => $this->upload->display_errors());
    $this->load->view('profile_view', $error);
   }
   else
   {
    // success
    $data = array('upload_data' => $this->upload->data());
    $website = $this->input->post('website');
    $password = $this->input->post('password');

    // a model that deals with your image data
    $this->your_upload_model->add($website, $password, $data["file_name"]);

    $this->load->view('upload_success', $data);
    }}  

你得到的图片......最可悲的是,因为所有这些转录的尝试都在Profiler输出中传递了PostData,但我在指定的文件夹中没有头像,也没有更新db列该模型。我可能只需要为这种疯狂找到一个合适的替代品,并完全消失这条道路。这种体验实际上是大多数&#34;用户仪表板&#34;我在GitHub和Sourceforge上看过的脚本没有为潜在成员提供图像上传和数据插入的组合。我再给它几个小时直到午夜,然后我就冲了这个。

从Crapper中救出......其实几乎已经......
遗漏了表单验证,直到我可以得到最后一部分功能;

function update()
{
    if ($this->ion_auth->logged_in() && $this->input->server('REQUEST_METHOD') == 'POST') 
    {
        $avatar = array();

        $this->upload->initialize(array(
           'upload_path' => 'assets/images/avatars/',
           'allowed_types' => 'gif|jpg|jpeg|png',
           'file_name' => $_FILES['avatar']['name'],
           'overwrite' => TRUE,
           'max_size' => 10400,
        ));

         if ($this->upload->do_upload('avatar'))
         {
             if($_FILES['avatar']['error'] == 0)
             {
                $id = $this->ion_auth->get_user_id('id'); 
                $avatar = 'assets/images/avatars/' . $this->upload->data('file_name');
                $website = $this->input->post('website');
                $password = $this->input->post('password');

                 $data = array(
                     'avatar' => $avatar,
                     'website' => $website,
                     'password' => $password               
                 );
                 $this->db->set('avatar', $avatar);
                 $this->db->set('website', $website);
                 $this->db->set('password', $password);
                 $this->db->where('id', $id);
                 $this->ion_auth->update('users', $data);
                 redirect('profile', 'refresh');

             }
         }
         else
             {
                 // no file uploaded or failed upload
                 $this->load->view('edit_profile_view');                   
             }
     }
 }  

我将头像上传到我的目标文件夹并将路径信息插入到数据库中,但图像不会显示在目标页面上。要访问上传的图片,请使用;

<?php
 $user->avatar = !empty($this->upload->data('avatar')) ? $this->upload->data('avatar') : 'default.jpg';
?>
<img height="300px" width="300px" class="avatar img-circle" src="<?php echo base_url().$user->avatar.$this->upload->data('file_name'); ?>">  

我甚至没有得到破损的图像符号,只是图像所在的空白区域。这是我在此过程中遇到的最后一个问题。我能够将头像重复上传到目标文件夹并插入路径信息(这将转到名为avatar的数据库中的一列);

db table view

在使用ion_auth作为目标元素ID $user->avatar的同时尝试访问头像的最长时间,我无法在Ion_Auth文档中找到针对此情况的任何内容关于那里的图像和个人资料页面没有任何处理。即使尝试遵循 Avenir 的教程,也会让我完全迷失在内陆地区。我可以使用其他一些眼睛,因为我在刀刃上,只是勉强挂着试图解决这个问题。我距离我的解决方案只有一毫米,并且它周围都是漆黑的(哈哈!)。 我可以得到一个线索......某人......任何人......?

使用文档更有趣......

尽管HTML Helper - https://codeigniter.com/user_guide/helpers/html_helper.html#img上的文档真是令人大开眼界,但由于我无法使用条件显示设备显示头像,我仍然感到不安如果列avatar下有路径/文件条目,或者只显示已上传到目标文件夹路径的default.jpg文件。我尽可能优雅地尝试(即使用最少量的代码),但它只是采用两种方法;

  <?php
  // if the avatar has been uploaded then display it 
  if(isset($user->avatar))
  { 
  ?>
  <img src="<?php echo base_url().'assets/images/avatars/'.$user->avatar; ?>" class="avatar img-circle" alt="Profile Image" width="300px">
  <?php
  }
  else 
  { 
  ?>
   <img src="<?php echo base_url().'assets/images/avatars/default.jpg'; ?>" class="avatar img-circle" alt="Profile Image" width="300px">            
  <?php 
  } 
  ?>  

OR,直接从display default image if user have no photo codeigniter推断;

<?php
$user->avatar = !empty($this->upload->data('avatar')) ? $this->upload->data('avatar') : 'default.jpg';
?>
<img height="300px" width="300px" class="avatar img-circle" src="<?php echo base_url().'assets/images/avatars/'.$user->avatar; ?>">  

但是,我只获得default.jpg文件,而不是已成功加载到目标文件夹并且其路径已成功插入{{1}的相应用户头像列。叹:这将是一个漫长的夜晚......

下一步-TO-LAST-UPDATE

感谢@DFriend对您之前讨论的问题的测量反馈。我遇到的困难更多地与我使用avatar作为辅助安全毯的方式有关。您传达的Ion Auth想法与我在将相应的控制器视图页面中带来四个不同的表格结果时必须采用的default.jpg体操相似;

$data[]

非常感谢再次 @DFriend,但是我可能会搁置这种方法以便稍后重新审核,因为我主要关心的是如何在路上获取应用程序在过去的两天里,所有其他气瓶都经过无情测试。我真的很确定我会去帮助我在这个问题范围内达到既定目标。令人痛苦,但我需要休息一下,所以我可以用新的眼睛接近它并关闭这个问题。这绝对没有结束(哈哈!)......我此时只是喝醉了。还要感谢所有人都关注这个问题。

2 个答案:

答案 0 :(得分:1)

此答案假设不需要头像。所以,我没有使用字段验证回调。

<强>控制器

function update() //"action" method from submission form 
{
    if($this->input->server('REQUEST_METHOD') === 'POST')
    {
        //no rules on the next one so what's the point?         
        //$this->form_validation->set_rules('website', 'Website');
        $this->form_validation->set_rules('password', 'Password', 'trim|min_length[4]|max_length[32]');

        $this->form_validation->set_message('min_length', 'This %s must have at least %s characters');
        $this->form_validation->set_message('max_length', 'This %s must have at least %s characters');

        if($this->form_validation->run() == TRUE)
        {
            $id = $this->ion_auth->get_user_id('id'); //$id will be NULL if not logged in   

            //Get the info from the form
            $website = $this->input->post('website');
            $password = $this->input->post('password');

            $is_avatar = $this->image_upload();
            if(is_string($is_avatar))
            {
                $this->load->view('profile_view', ['error' => $is_avatar]);
            }
            elseif($is_avatar === TRUE)
            {
                // to get image file name from upload script to be stored in the database
                $avatar = $this->upload->data('file_name');

                //use the next line if you want the full path instead of just the name
                //$avatar = $this->upload->data('full_path');
            }
            else
            {
                $avatar = NULL;
            }

            $this->load->model('profile_model');
            $this->profile_model->updateProfile($id, $avatar, $website, $password);
        }
        else //validation failed
        {
            //if you do this you loose the form_validation errors
            redirect('profile', 'refresh');
            //what you maybe want instead is something like
            //$this->load->view('profile_view'); //if that is where the form you just processed is
        }
    }
    //Not a POST call - go to profile page
    redirect('profile', 'refresh');
}

/**
 * Does the file upload
 * Returns NULL, boolean or string 
 *    NULL if no file posted, 
 *    TRUE if upload worked, 
 *    string if error
 */
function image_upload() //callback for previous update function
{
    if($_FILES['avatar']['size'] === 0)
    {
        return NULL;
    }
    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'gif|jpg|jpeg|png';
    $config['file_name'] = 'avatar_'.substr(md5(rand()), 0, 7);
    $config['overwrite'] = true; //will never happen because of previous setting
    $config['max_size'] = 10400;

    $this->load->library('upload', $config);
    //you already initializd the library by passing $config in the previous line
    //$this->upload->initialize($config);

    $is_uploaded = $this->upload->do_upload('avatar');

    if(!$is_uploaded)
    {
        return $this->upload->display_errors();
    }

    return TRUE;
}

<强>模型

通过查找$id来回答插入或更新问题。如果没有设置,那么我们有insert的新用户。如果设置了$id,则表示用户存在,请执行update

//function to update user_profile    
function updateProfile($id, $avatar = NULL, $website = NULL, $password = NULL)
{
    if(isset($avatar))
    {
        $this->db->set('avatar', $avatar);
    }

    if(isset($website))
    {
        $this->db->set('website', $website);
    }

    if(isset($password))
    {
        $this->db->set('password', $password);
    }

    //$id will  be set if logged in. 
    if(isset($id))
    {
        return $this->db
                        ->where('id', $id)
                        ->update('users');
    }

    //Not logged in - add new user with insert
    //make an insert and if it returns true the return the new id of inserted record, else return false
    return $this->db->insert('users') ? $this->db->insert_id() : FALSE;
    //but what you probably really want to do is create a new user via ion_auth. Right?
}

回复头像或默认图片问题

如果我错了,请纠正我,但$user->avatar具有avatar表中users字段的值 - 对吗?如果这是正确的,那么在我看来最简单的事情就是始终在avatar字段中存储

例如,当用户首次创建时,您存储他们提供的头像,如果他们不提供您存储的默认值.jpg。与配置文件更新类似 - 如果它们提供图像然后存储它,否则保持字段保持原样 - default.jpg。使用这种方法,您知道该表将始终提供显示的内容。因此,不需要进一步的逻辑。

下面是一对夫妇实际展示图片供您考虑。但首先,在您的问题中对代码进行一次评论。你展示了这行代码。

<img src="<?php echo base_url().'assets/images/avatars/'.$user->avatar; ?>" class="avatar img-circle" alt="Profile Image" width="300px">

如果$user->avatar包含字符串&#39; assets / images / avatars / LeeDavis.jpg&#39;然后你提供了两次路径,结果HTML将沿着这些行。

<img src="http://example.com/assets/images/avatars/assets/images/avatars/LeeDavis.jpg" ...and the rest... />

正如您所看到的,/assets/images/avatarssrc字符串中两次。

行。在实际显示图像。

假设您将$user对象传递给视图

 <img src="<?php echo base_url($user->avatar); ?>" class="avatar img-circle" alt="Profile Image" width="300px">

或者,如果使用HTML Helper,您可以在显示配置文件的控制器中执行此操作

//assuming that $data is being used to send pass variables to the view
$data['avatar_properties'] = array(
        'src'   => $user->avatar,
        'alt'   => "Profile Image",
        'class' => "avatar img-circle",
        'width' => '300',
);

然后在视图文件中

<?php echo img($avatar_properties); />

答案 1 :(得分:0)

这是问题的令人满意的解决方案;

function update()
{
if ($this->ion_auth->logged_in() && $this->input->server('REQUEST_METHOD') == 'POST') 
{
    $avatar = array();

    $user = $this->ion_auth->user()->row();
    $_FILES['avatar']['name'] = $user->avatar;

    // File upload script
    $this->upload->initialize(array(
       'upload_path' => 'assets/images/avatars/',
       'allowed_types' => 'gif|jpg|jpeg|png',
       'maintain_ratio' => TRUE,
       'max_width' => 300,
       'max_height' => 300,
       'encrypt_name' => TRUE,
       'remove_spaces' => TRUE,
       'xss_clean' => TRUE,
       'file_name' => $_FILES['avatar']['name'],
       'overwrite' => TRUE,
       'max_size' => 10400,
    ));

    // validate the POST data
    $this->load->library('form_validation');
    $this->form_validation->set_rules('avatar', 'Profile Picture', 'trim');
    $this->form_validation->set_rules('mobile', 'Mobile', 'trim');
    $this->form_validation->set_rules('skype', 'Skype', 'trim');
    $this->form_validation->set_rules('twitter', 'Twitter', 'trim');
    $this->form_validation->set_rules('googleplus', 'Googleplus', 'trim');
    $this->form_validation->set_rules('youtube', 'YouTube', 'trim');
    $this->form_validation->set_rules('vimeo', 'Vimeo', 'trim');
    $this->form_validation->set_rules('website', 'Website', 'trim');
    $this->form_validation->set_rules('career', 'Career', 'trim');
    $this->form_validation->set_rules('company', 'Company', 'trim');
    $this->form_validation->set_rules('password', 'Password', 'trim|min_length[6]|max_length[32]');

    $this->form_validation->set_message('min_length', 'This %s must have at least %s characters');
    $this->form_validation->set_message('max_length', 'This %s must have at least %s characters');

     if ($this->upload->do_upload('avatar'))
     {
         if($_FILES['avatar']['error'] == 0)
         {
            $id = $this->ion_auth->get_user_id('id'); 
            $avatar = $this->upload->data('file_name');
            $mobile = $this->input->post('mobile', true);
            $skype = $this->input->post('skype', true);
            $twitter = $this->input->post('twitter', true);
            $googleplus = $this->input->post('googleplus', true);
            $youtube = $this->input->post('youtube', true);
            $vimeo = $this->input->post('vimeo', true);
            $website = $this->input->post('website', true);
            $career = $this->input->post('career', true);
            $company = $this->input->post('company', true);
            $password = $this->input->post('password', true);   

             $data = array(
                 'avatar' => $avatar,
                 'mobile' => $mobile,
                 'skype' => $skype,
                 'googleplus' => $googleplus,
                 'youtube' => $youtube,
                 'vimeo' => $vimeo,
                 'website' => $website,
                 'career' => $career,
                 'company' => $company,
                 'password' => $password               
             );

               $this->db->set('avatar', $avatar);
               $this->db->set('mobile', $mobile);
               $this->db->set('skype', $skype);
               $this->db->set('googleplus', $googleplus);
               $this->db->set('youtube', $youtube);
               $this->db->set('vimeo', $vimeo);
               $this->db->set('website', $website);
               $this->db->set('career', $career);
               $this->db->set('company', $company);
               $this->db->set('password', $password);
               $this->db->where('id', $id);
               $this->ion_auth->update($user->id, $data);
               redirect('profile', 'refresh');
         }
     }
     else
     {
        // no file uploaded or failed upload
        $this->load->view('edit_profile_view');                   
     }
   }
}  

我无法放手(哈哈!)。如果我不能在同一页面上为潜在用户提供一些本地链接汁及其吸引人的化身的好处,为什么我会成为一名优秀的开发者;

Success imagery

我想再次公开地感谢 @DFriend ,因为我觉得他们有一种方法来表达答案,迫使你面对任何问题的未经考虑的方面(具体:我的小化身崩溃);

<?php
if (empty($user->avatar)){          
?>
<img height="300px" width="300px" class="avatar img-circle" src="<?php echo base_url().'assets/images/avatars/default.jpg'; ?>">
<?php } else {?>            
<img height="300px" width="300px" class="avatar img-circle" src="<?php echo base_url(). 'assets/images/avatars/' . $user->avatar; ?>">  
<?php } ?>

通过这个解决方案,我现在拥有一个功能齐全的基本发布应用程序,完成了我在近十一个月前开始执行的任务。感谢任何偶然发现这种情况或处于相同情况的人,并且你能够从我的问题中拿走一些东西。 Inebriation流程初始化(lol!)......