I have a combobox in my html view and a controller, my requirement is to pass selected item text from html view to controller at the same time upload an image to server. upload_control/do_upload
method for uploading image to server
<?php echo form_open_multipart('upload_control/do_upload');?> <input type="file" id="bt_chooseImage" name="userfile"/><br> <select name="category_images" id="combo_category"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> <input type="submit" id="bt_uploadImage" value="Submit"/><br>
Please note I already used a
<?php echo form_open_multipart('upload_control/do_upload');?>
already checked on onchange="this.form.submit()"
when i use onchange file uploading not working
Thank you for your help.
You can simple can access that by using
$val = $_POST['category_images'];
Or in CI method
$val = $this->input->post('category_images');
Change this line :
<select name="category_images" id="combo_category">
to
<select name="category_images" id="combo_category" onchange="this.form.submit()">
Then in your controller upload_control/do_upload, you can get the selected value using :
echo $this->input->post('category_images');
For processing the uploaded file, you may use Codeigniter File Upload library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.