Welcome Guest, Not a member yet? Register   Sign In
Send File by Email through Form on Web Site?
#21

[eluser]invision[/eluser]
Whenever I upload a file and submit the form, it doesn't seem to store the data in $file_name.

I try this:

Code:
$file_name = $this->upload->do_upload(); // _do_upload() should return the path and name of the uploaded file
die($file_name);

and my output is blank.


Anyone?
#22

[eluser]invision[/eluser]
Got it working Smile

Took the dive and went in head first.

Here's my final code I used in case it helps out others.

Code:
function apply($slug=0){
  
    $slug = $this->input->post('slug');
    $data['page_data'] = $this->MVacancies->getVacancyItem($slug);
    
    $data['title'] = $data['page_data']['title'];
    $data['body'] = $data['page_data']['body'];
    $title = $data['title'];
    
    $data['main'] = 'vacancies_apply';
    $this->load->vars($data);
    $this->load->view('template');
        
    if(isset($_FILES['userfile']['name']))
        {        
        
        $config['upload_path'] = '../uploads/';
            $config['allowed_types'] = 'gif|jpg|png';
            $config['max_size']    = '100';
            $config['max_width']  = '1024';
            $config['max_height']  = '768';
            
            $this->load->library('upload', $config);
            $this->upload->initialize($config);
          
            if ( ! $this->upload->do_upload())
            {
                $error = array('error' => $this->upload->display_errors());
                echo $config['upload_path'];
                $this->load->view('upload_form', $error);
            }    
            else
            {
                  $data = array('upload_data' => $this->upload->data());
                
            $email = 'no-reply';
            
            $file_name = !empty($data['upload_data']) ? $data['upload_data']['full_path'] : NULL ;
            //$file_name = $this->do_upload(); // _do_upload() should return the path and name of the uploaded file
            $this->email->attach($file_name);
      
            $message = "$email has applied for the $title job.";
            $this->email->from($email, '[email protected]');
            $this->email->to('[email protected]');
            
            $this->email->subject('Application for ' . $title . ' Job');
            $this->email->message($message);
            
            $this->email->send();
            
            // redirect user
            
            $this->load->view('form_success');
            
            die('Application sent successfully. Good luck!');
            // redirect to success page
        }
        
        }
        else
        {
            
            // exit
            
        }
    
  }

I think I'm going to try build a Blog with CodeIgniter and see how I go. Best way to learn I feel.


Thanks again
#23

[eluser]eoinmcg[/eluser]
good work.

and i'll bet it feels much more rewarding having solved it youself Wink
#24

[eluser]invision[/eluser]
It really does Smile

I've got a strange personality in that (especially with code) if I'm struggling with it, I'll seek help straight away. Instead of perhaps working away at it and breaking down the problem.


Thanks again.
#25

[eluser]Mr. Gibon[/eluser]
You may also look at this:

http://net.tutsplus.com/videos/screencas...tch-day-3/




Theme © iAndrew 2016 - Forum software by © MyBB