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.
php file-upload yii2
add a comment |
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.
php file-upload yii2
1
where is your model code you need to add therules()
set there for the fieldimage
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
add a comment |
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.
php file-upload yii2
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
php file-upload yii2
asked Nov 10 at 15:23
Gaston Berenstein
133
133
1
where is your model code you need to add therules()
set there for the fieldimage
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
add a comment |
1
where is your model code you need to add therules()
set there for the fieldimage
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
add a comment |
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.',
],
add a comment |
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.',
],
add a comment |
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.',
],
add a comment |
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.',
],
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.',
],
edited Nov 10 at 20:33
answered Nov 10 at 20:23
Muhammad Omer Aslam
11.9k62344
11.9k62344
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
where is your model code you need to add the
rules()
set there for the fieldimage
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