Jest problem ze ścieżką i nie wiem jak edytować akcje edytuj
The file "G:\xampp5.6\htdocs\future\future/web/uploads/images/G:\xampp5.6\tmp\phpB0E6.tmp" does not exist
<?php
namespace AppBundle\Controller;
use AppBundle\Entity\Blog;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\File\File;
/**
* Blog controller.
*
* @Route("blog")
*/
class BlogController extends Controller
{
/**
* Lists all blog entities.
*
* @Route("/blog", name="blog_index")
* @Method("GET")
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$blogs = $em->getRepository('AppBundle:Blog')->findAll();
return $this->render('blog/index.html.twig', array(
'blogs' => $blogs,
));
}
/**
* Creates a new blog entity.
*
* @Route("/new", name="blog_new")
* @Method({"GET", "POST"})
*/
public function newAction(Request $request)
{
$blog = new Blog();
$form = $this->createForm('AppBundle\Form\BlogType', $blog);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
/**
* @var UploadedFile $file
*/
$file=$blog->getImage();
$fileName=md5(uniqid()).'.'.$file->guessExtension();
$file->move(
$this->getParameter('image_directory'),$fileName
);
$blog->setImage($fileName);
$em = $this->getDoctrine()->getManager();
$em->persist($blog);
$em->flush();
return $this->redirectToRoute('blog_show', array('id' => $blog->getId()));
}
return $this->render('blog/new.html.twig', array(
'blog' => $blog,
'form' => $form->createView(),
));
}
/**
* Finds and displays a blog entity.
*
* @Route("/{id}", name="blog_show")
* @Method("GET")
*/
public function showAction(Blog $blog)
{
$deleteForm = $this->createDeleteForm($blog);
return $this->render('blog/show.html.twig', array(
'blog' => $blog,
'delete_form' => $deleteForm->createView(),
));
}
/**
* Displays a form to edit an existing blog entity.
*
* @Route("/{id}/edit", name="blog_edit")
* @Method({"GET", "POST"})
*/
public function editAction(Request $request, Blog $blog)
{
$blog->setImage(
new File($this->getParameter('image_directory').'/'.$blog->getImage())
);
$deleteForm = $this->createDeleteForm($blog);
$editForm = $this->createForm('AppBundle\Form\BlogType', $blog);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('blog_edit', array('id' => $blog->getId()));
}
return $this->render('blog/edit.html.twig', array(
'blog' => $blog,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Deletes a blog entity.
*
* @Route("/{id}", name="blog_delete")
* @Method("DELETE")
*/
public function deleteAction(Request $request, Blog $blog)
{
$form = $this->createDeleteForm($blog);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($blog);
$em->flush();
}
return $this->redirectToRoute('blog_index');
}
/**
* Creates a form to delete a blog entity.
*
* @param Blog $blog The blog entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm(Blog $blog)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('blog_delete', array('id' => $blog->getId())))
->setMethod('DELETE')
->getForm()
;
}
}