issue with uploader |
Hi,
I am trying to understand the uploader. I have a uploader.php with the config in and it does work if I break the code inside it, so I know its being loaded. I have this process at the moment and it works and adds the bit to the database but its not uploading the image. PHP Code: public function upload_image_process(){ I feel i am not using it right but I have looked at the docs and I cannot see any issue. Thanks, Doomie
you are not showing your code - you have to create the configs and load the upload library with the configs.
the most common issue is that you have not changed the permissions on the folder you are trying to upload to. otherwise i would google for a tutorial that will take you step by step.
The config is being auto loaded in uploader.php as stated above which is in the tutorial in the docs, the folder is also set to 777 as in the docs.
04-07-2016, 04:54 PM
(This post was last modified: 04-07-2016, 04:57 PM by PaulD. Edit Reason: Type )
You are redirecting to the admin/dashboard in all circumstances, but you could be missing an error message.
Try doing something like: PHP Code: if ( ! $this->upload->do_upload($upload_image)) Perhaps your path/to/directory is not set correctly, or it is the image type, or the size etc etc. You should always be checking and reporting back to the user when an error occurs. Otherwise, how do you or the user know what is going on? Hope that helps, Paul PS Am just using the 'show_error' for simplicity here, it is a quick solution while testing or developing. Of course normally you would have a user error view and/or error logging in place of some description.
04-08-2016, 12:28 PM
(This post was last modified: 04-08-2016, 12:30 PM by doomie22. Edit Reason: added php code )
I am getting the following error.
Upload Errors: You did not select a file to upload. This is the form section of it. PHP Code: <?php echo form_upload(array('id' => '1', 'name' => 'upload_image', 'class' => 'form-control')); ?> I really have no idea why it is saying that as I have unless it's not pulling it to the process.
04-08-2016, 12:37 PM
(This post was last modified: 04-08-2016, 12:48 PM by PaulD. Edit Reason: Missed your quote: added new suggestion )
Hi,
OK, at least you have an idea now of why your file is not uploading. It is probably a field name error. I see in your controller you are referring to PHP Code: $this->input->post('image_name') and PHP Code: $this->input->post('upload_image') Check what the name of your file input field actually is. Hope that helps, Paul. PS Just noticed you quoted your form section above. Can you paste the HTML of the form that is being generated? Try this: Change PHP Code: $this->upload->do_upload($upload_image); to PHP Code: $this->upload->do_upload('upload_image');
again its easier to help you if you show all your code. the form open needs to be multipart
form_open_multipart('uploadphoto'); the form field needs to be type=file <input type="file" name="filename" size="20" /> |
Welcome Guest, Not a member yet? Register Sign In |