100% рабочий правильный код, длинный, но полезный.НЕТ - пустая трата времени, наслаждайтесь!
//View
<?php echo form_open_multipart('Jobs_portal/job_apply')?>
<input type="file"
name="userfile" accept="application/msword,application/pdf"
required="">
<button type="submit">Submit</button>
</form>
//end view
//Controller <Jobs_portal>
public function job_apply()
{
$q=$this->file_upload(); //calling function file_upload
if ($q) {
$file_attribute=$this->upload->data();
$file_name=$file_attribute['file_name'];
$file_path=$file_attribute['file_path'];
//calling function attachment_mail to send pdf
$this->attachment_mail($file_path,$file_name);
}
}
public function file_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'doc|pdf';
$config['max_size'] = 9000;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('userfile'))
{
$this->upload->display_errors();
echo "Sorry! Apply again. Check Your Resume Format";
return false;
}
else
{
echo "i'll reply you after check your Resume. Thanks!";
return true;
}
}
public function attachment_mail($file_path,$file_name)
{
$this->load->library('email');
$this->load->helper('path');
$this->email->from('No-Reply@ie.com', 'Resume Receive');
$this->email->to('umairhanif2054602@gmail.com');
$this->email->subject('Apply for Job ');
$this->email->message('Sir I have attached my Resume for Job');
$this->email->attach($file_path.file_$name);
$this->email->send();
echo $this->email->print_debugger();
}
//end