Can't upload files larger than 97.66 KB in Yii2 Framework with Kartik's FileInput widget









up vote
1
down vote

favorite












When I try to upload a file larger than 97.66 KB I get this error (translated from spanish):




"File is too large. Its size cannot exceed 97.66 Kib."




This is my widget setup:



Modal::begin([
//'title'=>'File Input inside Modal',
'header' => 'Agregar foto',
'toggleButton' => [
'label'=>'Agregar foto',
'class'=>'btn btn-default',
//'href' => Url::to(['afiliado/foto']),
'value' => Url::to('index.php?r=afiliado/foto&id=' . $model->id),
],
]);
echo $form->field($model, 'image')->widget(FileInput::classname(), [
'options' => ['accept' => 'image/*'],
'pluginOptions'=>[
'maxFileCount' => 1,
'allowedFileExtensions'=>['jpg','jpeg','gif','png'],
'showUpload' => false,
'maxImageWidth' => 2400,
'maxImageHeight' => 2400,
'resizeImage' => true,
'maxFilePreviewSize' => 10240,
'minImageWidth' => 50,
'minImageHeight'=> 50,
'browseIcon' => '<i class="glyphicon glyphicon-camera"></i> ',
'maxFileSize' => 1024
],
]);
Modal::end();


And in My php.ini, I set:



upload_max_filesize = 99MB
post_max_size = 100MB


Thanks in advance.










share|improve this question

















  • 1




    where is your model code you need to add the rules() set there for the field image here in your question
    – Muhammad Omer Aslam
    Nov 10 at 16:05










  • @MuhammadOmerAslam that was the problem! I had to also change the rules() method, which was set to 100000. Thanks!
    – Gaston Berenstein
    Nov 10 at 20:19














up vote
1
down vote

favorite












When I try to upload a file larger than 97.66 KB I get this error (translated from spanish):




"File is too large. Its size cannot exceed 97.66 Kib."




This is my widget setup:



Modal::begin([
//'title'=>'File Input inside Modal',
'header' => 'Agregar foto',
'toggleButton' => [
'label'=>'Agregar foto',
'class'=>'btn btn-default',
//'href' => Url::to(['afiliado/foto']),
'value' => Url::to('index.php?r=afiliado/foto&id=' . $model->id),
],
]);
echo $form->field($model, 'image')->widget(FileInput::classname(), [
'options' => ['accept' => 'image/*'],
'pluginOptions'=>[
'maxFileCount' => 1,
'allowedFileExtensions'=>['jpg','jpeg','gif','png'],
'showUpload' => false,
'maxImageWidth' => 2400,
'maxImageHeight' => 2400,
'resizeImage' => true,
'maxFilePreviewSize' => 10240,
'minImageWidth' => 50,
'minImageHeight'=> 50,
'browseIcon' => '<i class="glyphicon glyphicon-camera"></i> ',
'maxFileSize' => 1024
],
]);
Modal::end();


And in My php.ini, I set:



upload_max_filesize = 99MB
post_max_size = 100MB


Thanks in advance.










share|improve this question

















  • 1




    where is your model code you need to add the rules() set there for the field image here in your question
    – Muhammad Omer Aslam
    Nov 10 at 16:05










  • @MuhammadOmerAslam that was the problem! I had to also change the rules() method, which was set to 100000. Thanks!
    – Gaston Berenstein
    Nov 10 at 20:19












up vote
1
down vote

favorite









up vote
1
down vote

favorite











When I try to upload a file larger than 97.66 KB I get this error (translated from spanish):




"File is too large. Its size cannot exceed 97.66 Kib."




This is my widget setup:



Modal::begin([
//'title'=>'File Input inside Modal',
'header' => 'Agregar foto',
'toggleButton' => [
'label'=>'Agregar foto',
'class'=>'btn btn-default',
//'href' => Url::to(['afiliado/foto']),
'value' => Url::to('index.php?r=afiliado/foto&id=' . $model->id),
],
]);
echo $form->field($model, 'image')->widget(FileInput::classname(), [
'options' => ['accept' => 'image/*'],
'pluginOptions'=>[
'maxFileCount' => 1,
'allowedFileExtensions'=>['jpg','jpeg','gif','png'],
'showUpload' => false,
'maxImageWidth' => 2400,
'maxImageHeight' => 2400,
'resizeImage' => true,
'maxFilePreviewSize' => 10240,
'minImageWidth' => 50,
'minImageHeight'=> 50,
'browseIcon' => '<i class="glyphicon glyphicon-camera"></i> ',
'maxFileSize' => 1024
],
]);
Modal::end();


And in My php.ini, I set:



upload_max_filesize = 99MB
post_max_size = 100MB


Thanks in advance.










share|improve this question













When I try to upload a file larger than 97.66 KB I get this error (translated from spanish):




"File is too large. Its size cannot exceed 97.66 Kib."




This is my widget setup:



Modal::begin([
//'title'=>'File Input inside Modal',
'header' => 'Agregar foto',
'toggleButton' => [
'label'=>'Agregar foto',
'class'=>'btn btn-default',
//'href' => Url::to(['afiliado/foto']),
'value' => Url::to('index.php?r=afiliado/foto&id=' . $model->id),
],
]);
echo $form->field($model, 'image')->widget(FileInput::classname(), [
'options' => ['accept' => 'image/*'],
'pluginOptions'=>[
'maxFileCount' => 1,
'allowedFileExtensions'=>['jpg','jpeg','gif','png'],
'showUpload' => false,
'maxImageWidth' => 2400,
'maxImageHeight' => 2400,
'resizeImage' => true,
'maxFilePreviewSize' => 10240,
'minImageWidth' => 50,
'minImageHeight'=> 50,
'browseIcon' => '<i class="glyphicon glyphicon-camera"></i> ',
'maxFileSize' => 1024
],
]);
Modal::end();


And in My php.ini, I set:



upload_max_filesize = 99MB
post_max_size = 100MB


Thanks in advance.







php file-upload yii2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 15:23









Gaston Berenstein

133




133







  • 1




    where is your model code you need to add the rules() set there for the field image here in your question
    – Muhammad Omer Aslam
    Nov 10 at 16:05










  • @MuhammadOmerAslam that was the problem! I had to also change the rules() method, which was set to 100000. Thanks!
    – Gaston Berenstein
    Nov 10 at 20:19












  • 1




    where is your model code you need to add the rules() set there for the field image here in your question
    – Muhammad Omer Aslam
    Nov 10 at 16:05










  • @MuhammadOmerAslam that was the problem! I had to also change the rules() method, which was set to 100000. Thanks!
    – Gaston Berenstein
    Nov 10 at 20:19







1




1




where is your model code you need to add the rules() set there for the field image here in your question
– Muhammad Omer Aslam
Nov 10 at 16:05




where is your model code you need to add the rules() set there for the field image here in your question
– Muhammad Omer Aslam
Nov 10 at 16:05












@MuhammadOmerAslam that was the problem! I had to also change the rules() method, which was set to 100000. Thanks!
– Gaston Berenstein
Nov 10 at 20:19




@MuhammadOmerAslam that was the problem! I had to also change the rules() method, which was set to 100000. Thanks!
– Gaston Berenstein
Nov 10 at 20:19












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










You need to get the file using UploadedFile::getInstance('image'), and change you model rules to use maxSize around 1024 * 1024 * 100 to set limit around 100MB



[['image'],
'file',
'skipOnEmpty' => false,
'extensions' => 'jpg, png, gif, jpeg',
'maxSize' => 1024 * 1024 * 100,
'tooBig' => 'The file was larger than 100MB. Please upload a smaller file.',
],





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240386%2fcant-upload-files-larger-than-97-66-kb-in-yii2-framework-with-kartiks-fileinpu%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    You need to get the file using UploadedFile::getInstance('image'), and change you model rules to use maxSize around 1024 * 1024 * 100 to set limit around 100MB



    [['image'],
    'file',
    'skipOnEmpty' => false,
    'extensions' => 'jpg, png, gif, jpeg',
    'maxSize' => 1024 * 1024 * 100,
    'tooBig' => 'The file was larger than 100MB. Please upload a smaller file.',
    ],





    share|improve this answer


























      up vote
      1
      down vote



      accepted










      You need to get the file using UploadedFile::getInstance('image'), and change you model rules to use maxSize around 1024 * 1024 * 100 to set limit around 100MB



      [['image'],
      'file',
      'skipOnEmpty' => false,
      'extensions' => 'jpg, png, gif, jpeg',
      'maxSize' => 1024 * 1024 * 100,
      'tooBig' => 'The file was larger than 100MB. Please upload a smaller file.',
      ],





      share|improve this answer
























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        You need to get the file using UploadedFile::getInstance('image'), and change you model rules to use maxSize around 1024 * 1024 * 100 to set limit around 100MB



        [['image'],
        'file',
        'skipOnEmpty' => false,
        'extensions' => 'jpg, png, gif, jpeg',
        'maxSize' => 1024 * 1024 * 100,
        'tooBig' => 'The file was larger than 100MB. Please upload a smaller file.',
        ],





        share|improve this answer














        You need to get the file using UploadedFile::getInstance('image'), and change you model rules to use maxSize around 1024 * 1024 * 100 to set limit around 100MB



        [['image'],
        'file',
        'skipOnEmpty' => false,
        'extensions' => 'jpg, png, gif, jpeg',
        'maxSize' => 1024 * 1024 * 100,
        'tooBig' => 'The file was larger than 100MB. Please upload a smaller file.',
        ],






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 10 at 20:33

























        answered Nov 10 at 20:23









        Muhammad Omer Aslam

        11.9k62344




        11.9k62344



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240386%2fcant-upload-files-larger-than-97-66-kb-in-yii2-framework-with-kartiks-fileinpu%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo