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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:40:40+00:00 2026-05-15T18:40:40+00:00

CONTROLLER class ImagesController extends AppController { var $name = ‘Images’; var $uses = array(‘Image’,’Person’);

  • 0

CONTROLLER

class ImagesController extends AppController {
    var $name = 'Images';
    var $uses = array('Image','Person');
    var $helpers = array('Html', 'Form');


        function add($idp = 0, $mac = 0) 
        {


            if (!empty($this->data) &&
                 is_uploaded_file($this->data['Image']['File']['tmp_name'])) {
                $fileData = fread(fopen($this->data['Image']['File']['tmp_name'], "r"),
                                         $this->data['Image']['File']['size']);

                $this->data['Image']['name'] = $this->data['Image']['File']['name'];
                $this->data['Image']['type'] = $this->data['Image']['File']['type'];
                $this->data['Image']['size'] = $this->data['Image']['File']['size'];
                $this->data['Image']['data'] = $fileData;
                $this->data['Image']['people_id'] = $idp;

                $this->Image->save($this->data);

                $this->redirect(array('controller' => 'People', 'action' => 'welcome',$mac));   

            }

        }

When I validate the form, I lose both parameters $idp and $mac.. How can I make them persist?

VIEW

<?php
    echo $form->create('Image', array('action' => 'add', 'type' => 'file'));
    echo $form->file('File');
    echo $form->submit('Upload');
    echo $form->end();
?>
  • 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-05-15T18:40:40+00:00Added an answer on May 15, 2026 at 6:40 pm

    You should add the following in your form element:

    'url'=>$this->Html->url()
    

    So the form will look like:

    echo $form->create('Image', array('type' => 'file', 'url'=>$this->Html->url()));
    

    Basically the $this->Html->url() get the current url with parameters and you pass it into the action of the form and if you submit in the same action (as it usually does) this should keep your parameters in tact.

    HTH

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

Sidebar

Related Questions

Ok i have this controller: class ExampleController extends AppController { var $name = 'Example';
I have got this controller: class Start extends CI_Controller{ var $base; var $css; function
Controller class PageController extends Zend_Controller_Action { public function editAction() { $this->view->attach('name' => 'crazor'); echo
I have the following controller: class Tests extends CI_Controller { public function update_record_test() {
I have a TableView controller class that uses a fetched results controller to display
This is my Welcome controller class Welcome extends MY_Controller { function __construct() { parent::__construct();
This is in a controller class LandingPage extends CI_Controller { public function startEncryptedSession(){ $this->load->library('session');
I have a controller class that uses asynchronous calls to perform some network operations.
i have controller class UserController (in controller folder) which extends BaseController (present in app
I have a controller called 'admin' class Admin extends CI_Controller { and under the

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.