last day (15 days later) » 

1:11 PM
0
Q: input type='file' have empty value and not pass from view to controller codeigniter

rana aqib JaveedView file <button type="button" class="button button--custom--grey button--main btn" id="logo">Upload Logo</button> <input type="file" class="form-control hidden" id="logo1"/><span id="mylogo">* Format must be jpg,jpeg or png</span> jquery $(document).on('click','#logo',function(){ $('in...

 
How do you check input value of file? where is your form in html. can you show little more code here?
 
<form action="<?= base_url();?>Home/add_dealer" method="post" enctype="multipart/form-data">
 
add this line to controller and check what you are getting echo "<pre>"; print_r($_FILES);
 
it return an array containing name and type .. but form_validation on logo1 is returning false
 
did you received file name in array?
 
1:11 PM
yes file name, type ,tmp_name but on logo1 required in form validation gives error
 
can you paste your printed output array?
 
when i select a file and inspect input file there is no value in that input filed
Array
(
[logo1] => Array
(
[name] => 1.png
[type] => image/png
[tmp_name] => C:\xampp\tmp\phpF07D.tmp
[error] => 0
[size] => 20338
)

)
 
have you write only this code to upload
$config['upload_path'] = 'C:\xampp\htdocs\devilbirds\images\uploads';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
$abc = $this->upload->do_upload('logo1');
var_dump($abc);exit();
?
 
i have also load img library
but form validation performs before this
 
can you show your controller code here?
 
1:16 PM
function add_dealer()
{
echo "<pre>"; print_r($_FILES);
$config['upload_path'] = 'C:\xampp\htdocs\devilbirds\images\uploads';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
$abc = $this->upload->do_upload('logo1');
$this->form_validation->set_rules('cname','CName','trim');
$this->form_validation->set_rules('logo1','Logo1','trim|required');
$this->form_validation->set_rules('address','Address','trim');
 
its not getting value due to required so i remove that and $abc = $this->upload->do_upload('logo1'); return true that means my file is uploading can you just tell me about how to save this file into the database with a temp name
i have checked that links many time but did not get the answer
 

last day (15 days later) »