php - File upload not working using codeignitor. Have no idea why -
i trying add together an, upload image directory in root. when nail submit button add together image shows error in if statement if false. have no thought doing wrong. help great, thanks.
to see have live visit here: http://travismichael.net/seniorproject
i have uploads folder in root , made writable.
here controller
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); }
here view
<!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 $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 $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"> 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>
some reason codeignitor forgot update documentation.
you need add together line right above phone call upload library
$this->upload->initialize($config);
php
No comments:
Post a Comment