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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:38:06+00:00 2026-06-10T11:38:06+00:00

I have followed this to add the functionality to upload files, but I have

  • 0

I have followed this to add the functionality to upload files, but I have a little problem. I actually copied the functions from the section Using Lifecycle Callbacks. Instead of class Document, I have a class Friend with this:

//...
/**
     * @Assert\File(maxSize="6000000")
     */
    public $picture;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $path;
//...

The upload and edit work, but I have problem when deleting. I want to have two options – Remove the picture and Delete the picture– the first will only set the current path to null and the file will remain in the folder where the files are stored while the second will set to path to null and will delete the file, too.

The bad news is that I cannot make the path to be null. The file is deleted, but the path stays.

This is the function from the documentation:

   /**
     * @ORM\PostRemove()
     */
    public function removeUpload()
    {
        if ($picture = $this->getAbsolutePath()) {
            unlink($picture);
        }
    } 

public function getAbsolutePath()
    {
        return null === $this->path ? null : $this->getUploadRootDir().'/'.$this->path;
    }

and this is the action in my controller:

public function removePictureAction($id)
    {
        $em = $this->getDoctrine()->getEntityManager(); 
         $friend = $em->getRepository('EMMyFriendsBundle:Friend')->find($id);
         $friend->removeUpload();
         $var=null;
         $friend->setPath($var);
         return $this->redirect($this->generateUrl('friend_id', array('id' => $id))); 
    }

but the path stays… How to delete it and set it to be null again?

  • 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-10T11:38:08+00:00Added an answer on June 10, 2026 at 11:38 am

    You need to persist your friend entity and flush the entity manager

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

Sidebar

Related Questions

I have followed this tutorial and added iAd to my app: http://bees4honey.com/blog/tutorial/how-to-add-iad-banner-in-iphoneipad-app/ But the
I followed this guide here perfectly and have gone through it again but when
I'm trying to understand the RPC functionality which GWT uses, and have followed this
So, I have followed this instruction from ADO.NET team blog to try to make
I have followed this guide: http://maven.apache.org/guides/plugin/guide-java-plugin-development.html I have created a maven-plugin project hello-maven-plugin with
I have followed this guide to install Solr in TomCat running on Windows Server
Hi have followed this tutorial using Core plot framework http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application My project compiles, but
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
I have followed this article and implemented my service and I can open the
I have followed this tutorial here as mentioned exactly I now try to run

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.