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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:57:09+00:00 2026-05-27T01:57:09+00:00

I am using Zend Framework 1.11 and after editing a record, the image file

  • 0

I am using Zend Framework 1.11 and after editing a record, the image file fields is emptied as well even though no other image is uploaded.

I have solved before this problem with mysql using this in the sql query:

image=ifnull(%s, image)

And worked perfectly. I am working with Zend now and I am not sure how this can be done. Anybody can help please?

Controller code:

$input = $form->getValues();
        $item = Doctrine::getTable('Tcc_Model_Item')
            ->find($input['article_id']);

        $item->fromArray($input);
        $item->save();

Update is done using a doctrine model.

form field is:

$image = new Zend_Form_Element_File('image');
 $image->setLabel('Image')
        ->addValidator('IsImage')
        ->setDestination('../public/uploads')
        ->addValidator('Size', false, '404800')
        ->addValidator('Extension', false, 'jpg,png,gif')
        ->addValidator('ImageSize', false, array(
                        'minwindth' => 50,
                        'minheight' => 50,
                        'maxwidth' => 250,
                        'maxheight' => 250))
     ->setOptions(array('class' => 'create'));
  • 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-27T01:57:10+00:00Added an answer on May 27, 2026 at 1:57 am

    I thought to answer to my own question since I found a solution myself that my be of help to some else.

    So what I did to solve this problem is:

    1. added an hidden field to the form used to edit like this:

      $image = new Zend_Form_Element_Hidden(‘image’);

    2. changed to image file field (the new image to upload) with a different name like this:

      $image2 = new Zend_Form_Element_File(‘image2’);

    This way when editing the hidden field will contain the info of the “image” field if there is one.

    Then in the controller I simply have a if/else statement just before the save() like this:

    if(!empty($input['image2']))
           { 
                $item->image = $input['image2']; 
        } else { 
                $item->image = $input['image'];
            }
    
    
     $item->save();
    

    Hope it helps others with same issue.

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

Sidebar

Related Questions

Using Zend Framework, I've created a Model to insert a record into a database.
I'm using Zend Framework with Doctrine. I'm creating an object, editing, then saving it.
I am using Zend Framework and 3rd party application written in php for file
suppose I implemented my site using Zend Framework and then after some time scalability
Using Zend Framework, I need to (1) read a record from a MySQL database,
I am using Zend Framework(MVC part of it), and need to either redirect user
I am using Zend Framework's library to manage EC2 instances and AMI. However I
I set up a Zend Framework application using Zend_Tool, but I wanted multiple modules
I have a PHP MVC application using Zend Framework. As presented in the quickstart,
I am working on a Facebook game which is developed using Zend framework. Right

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.