Tutorial File Upload Class Problem |
[eluser]davehedgehog[/eluser]
Hey, so I was doing the tutorial and for the life of me I cant figure out why this error message keeps presenting itself? Parse error: syntax error, unexpected T_STRING, expecting ')' .......on line 13 here is the controller: <?php class Upload extends CI_Controller { public function __construct() { parent::__construct(); $this->load->helper(array('form', 'url)); } public function index() { $this->load->view('upload_form'), array('error') => '')); } public 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_form',$error); } else { $data = array('upload_data' => $this->upload->data()); $this->load->view(upload_success', $data); } } } ?> really appreciate any help asap :/
[eluser]Sky Warden[/eluser]
That error means there's a typo in your script. I found it in this part : Code: public function index() Try to edit it into this : Code: public function index()
[eluser]davehedgehog[/eluser]
Woah cheers for the awesome fast reply. Sorry was quite late when I posted this so proberly wasnt that clear, either way doesn't work =( get the same error message. Ive tried different variations and also tried removing the function and it just prompts me with the same error =S any ideas?
[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums! Please remember to wrap your code in [code][/code] tags. It makes your code much easier to read. Please use the following code: Code: public function index()
[eluser]davehedgehog[/eluser]
Thanks =) and yeah Ill try and remeber to do that thanks again =) unfortunately that code still makes no difference, the problem still occurs :/
[eluser]TheFuzzy0ne[/eluser]
What's the error you have now? It can't be the same one. If it is, then you haven't updated the code correctly.
[eluser]davehedgehog[/eluser]
I re-did the whole page again using a different editor and it worked :S. same code, really weird. cheers for your help tho dude =)
[eluser]davehedgehog[/eluser]
Ok...same area, new problem was wondering if you guys could help. Basically I cant upload the file and keep getting 404 I have configured the Url etc and think it reads right like this: www.####.com/upload/do_upload Now my route config file reads: Code: $route['upload/upload_success'] = 'upload/upload_success'; My View is slightly different from the tutorial to allow me to browser folders. Code: <html> oh and the Success view Code: <html> And the Controller file: Code: <?php I have also set the uploads folder at the root with permissions set to 0777, as you may gether Ive been tinkering with different options most of the day and still baffled by the 404 =S Any help?
[eluser]TheFuzzy0ne[/eluser]
Your routes don't serve any purpose. It makes no sense rerouting to an identical URI. You should be able to safely remove those routes, since they basically do nothing. Also, please check the source code for the upload form, and double check that the URL is correct, by copying and pasting it directly into your browser.
[eluser]davehedgehog[/eluser]
Right... But I still need Code: $route['upload'] = 'upload'; to use the upload_form? yeah and slightly confused, source code of which upload form the view of controller?...or helper? |
Welcome Guest, Not a member yet? Register Sign In |