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 8093449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:30:21+00:00 2026-06-05T20:30:21+00:00

I am using CakePHP 2.1 and trying to upload files into server. I can

  • 0

I am using CakePHP 2.1 and trying to upload files into server.

I can successfully move the files to specified directory with manually naming a file, but its not taking the name from the
file type from view: register.

Database table: users

Id Auto_Increment
username
file_name

Controller : UsersController.php

public function register(){
    if ($this->request->is('post')){
        //   $this->data['User']['resume_file']['tmp_name'] = 'test.php';
        //  The above statement is working good

        if ($this->User->save($this->request->data)){
            $this->Session->setFlash('Message : ' . $this->data['User']['resume_file']['tmp_name']);
            //debug($this->data['User']['resume_file']['tmp_name']);

            // This is giving an error, while inserting
        }
    }
}

View : users/register.php

<?php
    echo $this->Form->create('User', array('type'=>'file'));
    echo $this->Form->input('username');
    echo $this->Form->input('file_name', array('type'=>'file', 'label'=>'Upload document') );
    echo $this->Form->end('Register');
?>

Error : Database error

INSERT INTO `sample_db`.`users` (`file_name`, `created`) VALUES (Array, '2012-06-14 08:10:10')

What i seen is that, while insert into table, Array is inserted thats and error Array to string conversion error in CakePHP
now how can i get the value of that input type : file_name in CakePHP

Or else if we can modify the data before saving with the below request statement..

$this->request->data

I tried to change that, with below statement

$this->data['User']['resume_file']['tmp_name'] = 'test.php';

but couldn’t its returning same error, any idea…

  • 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-05T20:30:22+00:00Added an answer on June 5, 2026 at 8:30 pm

    Try this:

    public function register(){
        if ($this->request->is('post')){
            $filename = $this->request->data['User']['file_name']['tmp_name'];
            $this->data['User']['file_name'] = $filename;
    
            if ($this->User->save($this->request->data)){
                $this->Session->setFlash('Message : ' . $filename);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to upload a file to my server using the CakePHP file upload
I am using cakephp 2.1 and i am trying to upload files and how
I'm trying to send an email with an attachment using CakePHP 2.0. The file
I'm using CakePHP 2.0 and I'm trying to understand how I can echo dynamic
I am using WebTechNick's file upload plugin to save images on my CakePHP site.
I am getting an error when trying to play a file in cakephp using
I'm using cakephp and trying to check if a table has data entered in
I'm using TCPDF in CakePHP and trying to make some background (grey) for few
i am trying to create a Radio button using Cakephp like the one the
I'm trying to create an XML sitemap using CakePHP, from a table which has

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.