php - Image Not Uploading - Codeigniter -
i have problem uploading image in codeigniter app i'm working on. code working when on pc (ubuntu) fine, it's given in tutorials. when i'm trying in (centos) server, it's giving error "you did not select file upload.".
just reference, i'll paste code here.
controller- upload1.php
<?php class upload1 extends ci_controller { function __construct() { parent::__construct(); $this->load->helper(array('form', 'url')); } function index() { $this->load->view('upload_form1', array('error' => ' ' )); } 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); if ( ! $this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); $this->load->view('upload_form1', $error); } else { $data = array('upload_data' => $this->upload->data()); $this->load->view('upload_success1', $data); } } } ?>
form - upload_form1.php
<html> <head> <title>upload form</title> </head> <body> <?php echo $error;?> <?php echo form_open_multipart('upload1/do_upload');?> <input type="file" name="userfile" size="20" /> <br /><br /> <input type="submit" value="upload" /> </form> </body> </html>
success page- upload_success1.php
<html> <head> <title>upload form</title> </head> <body> <h3>your file uploaded!</h3> <ul> <?php foreach ($upload_data $item => $value):?> <li><?php echo $item;?>: <?php echo $value;?></li> <?php endforeach; ?> </ul> <p><?php echo anchor('upload1', 'upload file!'); ?></p> </body> </html>
what problem? have "uploads" directory set 777. that's not reason. tried couple of solutions similar problems, isn't working. have missed obvious?
versions: server- php 5.3.13 (cli) pc- php 5.3.3 .
codeigniter same on local , remote machines- 2.1.3
i grateful suggestions!!
thank much
based on code, don't see if there form validation validate submitted input whether it's valid upload config or not. should first : check file you're trying upload appropriate upload config or not. think ci's upload class doesn't cover errors non valid input form. cmiiw.
Comments
Post a Comment