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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 530k
  • Answers 530k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You'll find the solution here: http://gist.github.com/572781 Let me copy it… May 16, 2026 at 11:28 pm
  • Editorial Team
    Editorial Team added an answer There are vendor specific ways to do that, therefore it… May 16, 2026 at 11:28 pm
  • Editorial Team
    Editorial Team added an answer I guess you want to create a NSMutableArray of NSMutableArrays:… May 16, 2026 at 11:28 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a simple controller which returns images: public class ImageController : Controller {
Controller: class CategoriesController < ApplicationController def create @category = Category.create(...) respond_to do |format| if
Controller: class GalleriesController < ApplicationController def index @galleries = Gallery.all end end View: <%
I have a controller class which spawns a window when a certain condition occurs.
I have the following controller: class FooController : Controller { public ActionResult SomeAction(id) {
Any idea how can i add my controller class as a observer for my
I've currently got a BaseController class that inherits from System.Web.Mvc.Controller . On that class
Ok heres the situation. I have a View controller class that serves as the
I have an ImagesController that kicks off a non-trivial save operation. Here's the high-level
I have the following scenario I want to add methods dynamically to a controller.

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.