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

The Archive Base Latest Questions

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

I am using cakephp 2.1 and i am trying to upload files and how

  • 0

I am using cakephp 2.1 and i am trying to upload files and how can i retrive the extension of the file.

Database/users

Id Auto_Increment
username
file_name

Controller/UsersController.php

public function register(){
            if ($this->request->is('post')){
                $filename = $this->data['User']['file_name']['name'];
                //$temp_ext = $this->data['User']['resume_file']['ext'];

                $this->Session->setFlash('Extension : ' . $temp_ext);
            }
}

When tried the above code, to get extension. it only gives single letters like L, r ie firt character of the filename but not extension

Now how can i get the extension of the file.. i gone through this link

http://api.cakephp.org/class/file

but could not understand to retrieve the file.


Adding a Debug report to @Julian Hollmann

array(
    'User' => array(
        'file_name' => array(
            'name' => '550992_234300256686731_213914803_n.jpg',
            'type' => 'image/jpeg',
            'tmp_name' => 'D:\xampp\tmp\php866F.tmp',
            'error' => (int) 0,
            'size' => (int) 42292
        )
    )
)
  • 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:28:44+00:00Added an answer on June 5, 2026 at 8:28 pm

    First of all, your data should be in $this->request->data

    If you want to see what’s in there, just do debug($this->request->data);

    Edit:
    The correct answer is:

    $filename = $this->request->data['User']['file_name']['name'];
    $extension = pathinfo($filename, PATHINFO_EXTENSION);
    

    See also php manual

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using CakePHP 2.1 and trying to upload files into server. I can
I'm trying to upload a file to my server using the CakePHP file upload
hi all I'm trying to search a database for a username using cakephp, the
I'm trying to send an email with an attachment using CakePHP 2.0. The file
I am getting an error when trying to play a file in cakephp using
I'm using CakePHP 2.0 and I'm trying to understand how I can echo dynamic
Using CakePHP 1.3 I'm trying to save some data to a MySQL database. The
I am doing a site in cakephp where users can upload videos and those
I am using WebTechNick's file upload plugin to save images on my CakePHP site.
I am using Ubuntu + cakephp 1.3. I am trying the database migration with

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.