0

我正在尝试添加一个图像,将图像上传到我的根目录中。当我点击添加图像的提交按钮时,它在 if 语句中显示错误,就好像它是错误的一样。我不知道我做错了什么。

看看我有什么现场访问:http: //travismichael.net/SeniorProject

我的根目录中有我的上传文件夹,我使它可写。

这是我的控制器

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

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

if ( !$this->upload->do_upload('userfile'))
{
  echo  '<p>IMAGE NOT WORKING</p>';
}
else
{
  $data = array('upload_data' => $this->upload->data());

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

这是我的看法

<!DOCTYPE html>
<?php $this->load->view('partials/page_head'); ?> 
<body>
<body class="home">
<div id="container">
<div id="top">
  <div class="topcenter">
    <h2><a class="addbtn">Add Folder</a></h2>
    <h2><a class="deletebtn" href="<?php echo base_url();?>index.php/home/delete">DeleteFolders</a></h2>
  </div>    
  <div class="navdescription"><span>Home</span></div>
</div>

  <div class="projectFolders">
  <?php foreach($foldername as $row) { ?>
    <div class="folder <?php echo $row->folderName; ?>">
      <button class="<?php echo $row->folderName; ?>"><?php echo $row->folderName; ?>    </button>
    </div>
    <script>
        $(function () {
          $('button.<?php echo $row->folderName; ?>').bind('click', 
            function() { $('.open.<?php echo $row->folderName;?>').show() });

          $('.gohome').bind('click', 
            function() { $('.open.<?php echo $row->folderName;?>').hide() });
        });
    </script>
  <?php } ?>

 <?php foreach($foldername as $row) { ?>
    <div class="open <?php echo $row->folderName; ?>">
      <h1><?php echo $row->folderName;?></h1>
      <a class="gohome">Home</a><a class="addimagebtn">Add Image</a>
        <div class="edititable" contenteditable="true" focus="true">
          Your Content Goes Here
        </div>
    </div>
  <?php } ?>
  <div class="uploadimage">
    <?php echo form_open_multipart('home/do_upload');?>
      <input type="file" name="userfile" size="20" />
      <br /><br />
      <input type="submit" value="Add Image" />
     </form>
   </div>
  </div>
  <div id="bottom">
  <div class="formWrapper">
    <form accept-charset="utf-8" method="post" action="<?php echo base_url(); ?>index.php/home/create" id="cf_form">
      <input type="text" name="folderName" placeholder="Enter new Folder" class="required" required/>
    <?php echo form_submit('createFolder', 'Create Folder'); ?>
    <?php echo form_close(); ?>
    <?php echo validation_errors('<p class="error">'); ?>
</div>
</div>  
</div><!-- End of container div -->
</body>
</html>
4

1 回答 1

0

某些原因 Codeignitor 忘记更新他们的文档。

您需要在调用上传库的位置正上方添加此行

$this->上传->初始化($config);

于 2013-02-11T22:29:57.473 回答