-1

I have form in html:

<form  enctype="multipart/form-data" id="client-form" method="post" accept-charset="UTF-8" action="{{ path('contact_form_message') }}" class="modal-form">
  <div class="row">
     <input title="attachment" type="file" class="pull-left file-inp" multiple name="files">
     <input type="hidden" name="MAX_FILE_SIZE" value="52428800" />
     <button href="#" id="submit" class="btn send static-form-button">Send</button>
  </div>
</form>

php:

 foreach ($files as $file) 
 {
    if ($file)
    {
        if ($file->getSize() > $this->container->getParameter('attachments_max_size', 52428800 ))
        {
            $message = "File size limit exceeds";
        }
        else
        {
            if(is_uploaded_file($file->getPathName()))
            {
                $fileName = uniqid().'_'.str_replace(' ','_',$file->getPathName().'.'.$file->guessExtension());
                $attachment = $file->move($attachments_dir, $fileName);
                $link = $request->getHost().'/uploads/media/attachments/'.$attachment->getFileName();
                $path = $attachment->getPathName();
            }
            else
            {
                $message = 'Error uploading file';
            }
        }
    }
}

But I have a problem that I can upload files size with max size of 1mb.
I want 50mb. What I am doing wrong?

P.S Maybe I must use jQuery for this?

Daniel Krom
  • 9,751
  • 3
  • 43
  • 44

1 Answers1

1

Double check the size limit in your php.ini file, maybe that is the restricting factor.

Although this value is supplied in the form the client should never be authoritative, anyone can change this locally.

TJHeuvel
  • 12,403
  • 4
  • 37
  • 46
  • That's why i do check in my controller. Yes, in my php.ini max_file_size = 2MB, i change it to 50, but it still doesn't work – asdasd asdasd Aug 25 '15 at 09:20
  • Did you restart the php daemon? When you change the configuration a restart is required. – TJHeuvel Aug 25 '15 at 09:21
  • Can you log the $file->getSize() and the `attachments_max_size` parameter? Maybe there is an Mb to MB conversion somewhere. – TJHeuvel Aug 25 '15 at 09:22