Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8754195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:34:19+00:00 2026-06-13T13:34:19+00:00

I am a new learner of cakephp 2.x. I want to build a simple

  • 0

I am a new learner of cakephp 2.x.
I want to build a simple form for user to upload their resume files, and then send them as email attachments.
Somehow I can’t find a way to attach uploaded file to email. Any help will welcome!
Here is my send.ctp:

<?php 
   echo $this -> Form -> create(null, array('enctype' =>'multipart/form-data'));
   echo $this -> Form -> input('first_name', array('type'=>'text')); 
   echo $this -> Form ->input('last_name', array('type'=>'text'));
   echo $this -> Form ->input('contact_number',array('type'=>'text')); 
   echo $this -> Form ->input('email',array('type'=>'text'));
   echo $this -> Form ->input('resume', array('type' => 'file',));
   echo $this -> Form ->end('Submit');      
?>

Here is my HomesController.php

<?php 
   class HomesController extends AppController {
public $name = 'Homes';
public $uses = null;
public $helpers = array('Html', 'Form');

    public function index() {
    }
public function send(){
   if (!empty($this->data)) {
      echo $this->data['last_name'];
      echo $this->data['contact_number'];
      echo $this->data['email'];
          echo $this->data['resume'];

      App::uses('CakeEmail', 'Network/Email');
      $email = new CakeEmail();
      $email->from('xyz@gmail.com');
          $email->to('abc@gmail.com');
          $email->subject('About');
          $email->attachments = array($this->data['resume']);
      $email->send($this->data['last_name']);
      $this->redirect(array('action' => 'index'));
   }
     }
   }?>

The email can actually send and be able to receive, but without attachment. When I try “echo $this->data[‘resume’]” it only display a string—‘Array’. But other fields like “echo $this->data[‘last_name’]” works properly.

http://cakebaker.42dh.com/2006/04/15/file-upload-with-cakephp/
Above one use database, I don’t wanna use database to store files. And it use cakephp 1.x which cannot run in 2.x.

How to do form-based file uploads in CakePHP?
This one doesn’t say how to attach files to email.

This is my Config/email.php, I use gmail smtp:
class EmailConfig {

public $default = array(
    'transport' => 'Smtp',
    'from' => 'XXX@gmail.com',
    //'charset' => 'utf-8',
    //'headerCharset' => 'utf-8',
);

public $smtp = array(
    'transport' => 'Smtp',
    'from' => array('XXX@gmail.com' => 'Sender'),
    'host' => 'smtp.gmail.com',
    'port' => 465,
    'timeout' => 30,
    'username' => 'XXX',
    'password' => '@password',
    'client' => null,
    'log' => false,
    //'charset' => 'utf-8',
    //'headerCharset' => 'utf-8',
);

public $fast = array(
    'from' => 'you@localhost',
    'sender' => null,
    'to' => null,
    'cc' => null,
    'bcc' => null,
    'replyTo' => null,
    'readReceipt' => null,
    'returnPath' => null,
    'messageId' => true,
    'subject' => null,
    'message' => null,
    'headers' => null,
    'viewRender' => null,
    'template' => false,
    'layout' => false,
    'viewVars' => null,
    'attachments' => null,
    'emailFormat' => null,
    'transport' => 'Smtp',
    'host' => 'localhost',
    'port' => 25,
    'timeout' => 30,
    'username' => 'user',
    'password' => 'secret',
    'client' => null,
    'log' => true,
    //'charset' => 'utf-8',
    //'headerCharset' => 'utf-8',
);

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:34:20+00:00Added an answer on June 13, 2026 at 1:34 pm

    $this->data['resume'] is an array that contains information about the file upload.

    The array looks something like this:

    array(
       'name' => '(filename)',
       'type' => '(filetype)',
       'tmp_name' => '(file location)',
       'error' => (int) 0,
       'size' => (int) 1
    )
    

    Try setting the attachment using:

    $email->attachments(array($this->data['resume']['name'] => $this->data['resume']['tmp_name']));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want a simple filter form, and a table below it. When the user
new on ruby and using windows xp and rails 3, i want to send
i am new opengl learner. i know there is build in function to draw
I am new learner to jquery/js. I am having difficulties making a scroll tab
i'm new at C Programming (i learned c++) i want to create a process
I am new to Python as I want to expand skills that I learned
I am a new visual basic learner and I already have some difficulties in
I am a very new zend framework and phpunit test learner. I have a
Hello stackoverflow pals.I am a new rails learner. My question is: I am listing
I'm a student and i want make a build tool as a side project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.