2014-06-10 3 views
0

사용자로부터 파일을 가져 와서 서버에 저장하지 않고 메일에 첨부해야합니다. Codeigniter에서 업로드 된 파일을 변수에 저장 한 다음 Codeigniter 전자 메일 라이브러리의 전자 메일에 첨부 할 수 있습니까? 그것을 성취하는 방법? CI에서 업로드 된 파일을 변수가 아닌 하드 드라이브에 저장하는 클래스 만 찾습니다.전자 메일에 양식 파일 첨부, Codeigniter

+0

무엇이 문제입니까? '$ this-> email-> attach()'http://ellislab.com/codeigniter/user-guide/libraries/email.html에서 전체 문서를 읽으려고 했습니까? 파일을 어디에 저장 하시겠습니까? 나는 당신이 성취하려고 시도하는 것이 완료 될 수 없다고 생각합니다. 파일에 무엇인가를 첨부 할 때 먼저 이메일에 첨부하기 전에 그것을 업로드해야합니다. – tomexsans

+0

그래서 나는 그것을 업로드하고, 첨부하고, 메일을 보낸 다음 서버에서 파일을 삭제해야합니까? – ddl

+0

발신자 (PHP)는 파일의 내용을 알아야합니다. – hice3000

답변

3

먼저 이것을 시도 및 전자 메일 라이브러리.

$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); 

    if (! $this->upload->do_upload()) 
    { 
     $error = array('error' => $this->upload->display_errors()); 

    } 
    else 
    { 
     $data = array('upload_data' => $this->upload->data()); 

    $this->load->library('email'); 

    $this->email->from('[email protected]', 'Your Name'); 
    $this->email->to('[email protected]'); 
    $this->email->cc('[email protected]'); 
    $this->email->bcc('[email protected]'); 

    $this->email->subject('Email Test'); 
    $this->email->attach('/path/to/file.ext'); 
    $this->email->message('Testing the email class.'); 

    $this->email->send(); 

    } 
+0

서버에 파일을 저장하지 않으려면 어떻게해야합니까? – ddl

+0

안되요. php에서 unlink() 함수를 사용하여 이메일을 보내면 파일을 삭제할 수 있습니다. –

+0

그럼 네가 할거야 : / – ddl

-1

이 하나

http://ellislab.com/codeigniter/user-guide/libraries/email.html 

그것은 잘 작동 해보십시오. 난 당신이 다음 라인을 첨부 이메일로 즉,

**$this->email->attach('/path/to/file.ext');** 

업로드 클래스의 아래 코드를 참조 이름과 파일의 경로를 통과 서버 디렉토리에 파일을 업로드해야 내 최근 프로젝트

+0

파일을 드라이브에 저장하지 않고 서버에 업로드하는 중 문제가 발생했습니다. – ddl

관련 문제