stdClass on controller |
[eluser]Sein Kraft[/eluser]
Quote:Fatal error: Cannot use object of type stdClass as array in E:\Server\htdocs\KL6G56PD8P\system\application\controllers\gallery.php on line 112I get this error from the next controller. Code: function submit() The line 112 is Code: $config['upload_path'] = './files/temp/'; Btw what do you think about the code? ![]()
[eluser]TheFuzzy0ne[/eluser]
The method you're calling on right at the top is returning an object, and you are trying to use it as an array. You're accessing the $_POST array directly, which is advised against. You call on $this->m_core->load_config() again when validation fails, which shouldn't be necessary. Your code at first glance also seems to lack error checking, but I'm not entirely sure if it's necessary. Other than that, you're code looks CI-exy.
[eluser]Sein Kraft[/eluser]
But it's not the $_POST who cause the error is the Code: $config['image_library'] = 'gd2'; What do you mean with CI-exy?
[eluser]pistolPete[/eluser]
Rename the $config array and it will work: Code: switch ($_POST['type']) Some additional suggestions: 1.) The second switch statement should be transformed into an if statement: Code: if($this->input->post('type') == 'Image') 2.) You can avoid copying/unlinking the file just to rename it: Get the latest CI version from SVN and use this setting: Code: $upload_config['file_name'] = 'put_your_new_filename.here'
[eluser]TheFuzzy0ne[/eluser]
The first sentence was addressing your problem, the rest were addressing your request "Btw what do you think about the code?". CI-exy = sexy, but in a CI way.
[eluser]Sein Kraft[/eluser]
Thanks a lot you two. Its working fine ![]() Btw i've the latest version of CI but its less code with copying/unlinking. |
Welcome Guest, Not a member yet? Register Sign In |