Help!! I can upload anything with codeigniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Help!! I can upload anything with codeigniter (/showthread.php?tid=30019) Pages:
1
2
|
Help!! I can upload anything with codeigniter - El Forum - 04-29-2010 [eluser]adekenny[/eluser] Hi, I really need help fast, there's this project i'm working on and i'm trying to incorporate a page that allows users to upload images to a directory. The problem is that it's just not working at all. I'v checked the code with the example on the user guide that there seems to be no problem with it. When i clicked the upload buttom it just wasn't giving any response at all - no even any error message. What are my not getting right? please see my controller code below. <?php class Upload extends Controller { var $base; var $css; var $my_menu; function Upload() { parent::Controller(); $this->base = $this->config->item('base_url'); $this->css = $this->config->item('css'); $this->load->library('menu'); $this->my_menu = $this->menu->show_menu(); $this->load->library('upload'); $this->load->library('session'); $this->load->helper(array('form', 'url')); } function do_upload() { if(!$this->upload->do_upload()) { $data['menu'] = $this->my_menu; $data['base'] = $this->base; $data['css'] = $this->css; $error = array('error' => $this->upload->display_errors()); $data['error'] = $error; $this->load->view('photo_upload_failed', $data); } else { $data['menu'] = $this->my_menu; $data['base'] = $this->base; $data['css'] = $this->css; $data = array ('upload_data' => $this->upload->data()); $this->load->view('upload_success', $data); } } } ?> I've already created a file in my config folder where i set all the default settings. Please see below. <?php if(!defined('BASEPATH')) { exit; } else { $config['upload_path'] = 'uploads'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '40'; $config['max_width'] = '50'; $config['max_height'] = '60'; $config['remove_spaces'] = TRUE; } ?> Many Thanks adekenny - Nigeria Help!! I can upload anything with codeigniter - El Forum - 04-29-2010 [eluser]pickupman[/eluser] Could you please post your view, so we can see what the form looks like. Are you using any javascript controls like jQuery where you are binding the click event of the submit button? Do you have write permissions to the uploads folder? What OS environment are you working on? Help!! I can upload anything with codeigniter - El Forum - 04-29-2010 [eluser]adekenny[/eluser] I've attached the view to this post. It was just displaying "ARRAY" instead of an error message or success message. The OS i'm using is windows XP and Windows 7 Professioal. Thanks for replying Help!! I can upload anything with codeigniter - El Forum - 04-29-2010 [eluser]adekenny[/eluser] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Sectech Univeristy Website</title> <base href= <?php echo "$base"; ?> /> <link rel="stylesheet" type="text/css" href= "<?php echo "$base/$css"; ?>" /> </head> <body> <div id="main_container"> <div id="header"><img src="header.jpg" /></div> <div id="menu"><?php echo $menu; ?></div> <div id="content"> <h3>Online Registration</h3> <p><span style="color:#990000; font-weight:bold">Uploading your picture.</span> </p> <br /> <?php $this->load->library('session'); $first_name = $this->session->userdata('firstname'); $last_name = $this->session->userdata('lastname'); echo "<p>Passport size photo for: $first_name $last_name is being uploaded.</p>"; ?> <?php $this->load->helper('form'); $this->load->helper('url'); echo'<br>'; echo form_open_multipart('upload/do_upload'); echo'<table>'; echo'<tr>'; echo'<td>'; echo form_upload($data); echo'<br>'; echo'<br>'; echo form_submit('mysubmit', 'Submit Post!'); ?> <br /><br /><br /><br /> </div> <div id="footer"> <P class="copyright">Copyright © 2010 Sectech University</P> <p class="designer">powered by <A href="http://www.sectechsystems.com">Sectech Systems</A></p> </div> </div> </div> </div> </body> </html> Help!! I can upload anything with codeigniter - El Forum - 04-29-2010 [eluser]adekenny[/eluser] This is the view the controller is meant to call if the upload fails. <?php $this->load->helper('form'); echo $error; echo'<br>'; echo form_open_multipart('upload/do_upload'); echo'<table>'; echo'<tr>'; echo'<td>'; echo form_upload('$data'); echo'<br>'; echo'<br>'; echo form_submit('mysubmit', 'Submit Post!'); echo form_close(); ?> Help!! I can upload anything with codeigniter - El Forum - 04-29-2010 [eluser]pickupman[/eluser] Try this: Code: //In View Help!! I can upload anything with codeigniter - El Forum - 04-29-2010 [eluser]Twisted1919[/eluser] On windows there's no need to check files write/read perms . Help!! I can upload anything with codeigniter - El Forum - 04-29-2010 [eluser]pickupman[/eluser] [quote author="Twisted1919" date="1272594244"]On windows there's no need to check files write/read perms .[/quote] Yes there is especially with XP Pro or greater. Some folders can have user permissions just like *nix, or be checked "Read Only". Make sure folder is not read only, and the group User is check for Full Access. Help!! I can upload anything with codeigniter - El Forum - 04-30-2010 [eluser]adekenny[/eluser] When i tried the code you sent, i got the following error message. Severity: Notice Message: Undefined property: CI_Loader::$upload Filename: views/photo_upload.php Line Number: 35 Fatal error: Call to a member function display_errors() on a non-object in C:\Program Files (x86)\EasyPHP 2.0b1\www\system\application\views\photo_upload.php on line 35 I've set the right file permission for the folder i'm uploading the files into. Could it be an operating systems issue? Help!! I can upload anything with codeigniter - El Forum - 04-30-2010 [eluser]pickupman[/eluser] Replace this line: Code: echo $this->upload->display_errors('<p>', '</p>'); With this: Code: echo @$errors; In your controller where you are checking upload add: Code: $data['errors'] = $this->upload->display_errors('<p>', '</p>'); |