Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UploadedData {
- /**
- * @Assert\File(maxSize="6000000")
- */
- public $file;
- /**
- * @Assert\NotBlank
- */
- public $name;
- }
- public function addAction(){
- $uploadedData = new UploadedData();
- $formUpload = $this->createFormBuilder($uploadedData)
- ->add('file')
- ->add('name')
- ->getForm();
- $debug = '';
- $photos = array();
- if ($this->get('request')->getMethod() === 'POST'){
- $formUpload->bindRequest($this->get('request'));
- if ($this->get('request')->get('submit-photo'))
- {
- for ($i = 0; $i < 3; $i++) {
- $photo = $this->get('request')->get("photo-".$i);
- if (isset($photo)){
- array_push($photos,$photo);
- }
- }
- if($formUpload->isValid())
- {
- $debug = $debug.' Upload OK';
- }else{
- $debug = $debug.' Invalid Upload';
- }
- }
- }
- return $this->container->get('templating')->renderResponse('LCShopBundle:Item:add.html.twig',
- array(
- 'formUpload' => $formUpload->createView(),
- 'photos' => $photos,
- 'debug' => $debug)
- );
- }
- {{ form_widget(formUpload.file) }}<input type="submit" name="submit-photo" value="Load">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement