-
Notifications
You must be signed in to change notification settings - Fork 140
option - accept => 'image/*' does not work as expected #106
Comments
Please, try with: https://github.com/blueimp/jQuery-File-Upload/wiki/Options#processqueue Edit: Documentation is wrong, on the client level we need to configure: https://github.com/blueimp/jQuery-File-Upload/wiki/Options#acceptfiletypes |
@tonydspaniard, alright, I tried this: <?= FileUpload::widget([
'model' => $uploadModel,
'attribute' => 'image',
'url' => ['document/upload'],
// 'options' => [
// 'accept' => 'image/*'
// ],
'clientOptions' => [
'acceptFileTypes' => '/(\.|\/)(gif|jpe?g|png)$/i',
'maxFileSize' => 2000000
],
... However, it did not really help me. I am still able to upload zip archives, etc I looked at this one - https://github.com/blueimp/jQuery-File-Upload/wiki/Options#processqueue, however no result as well. Could you please give minimum example of validation? |
@tonydspaniard any suggestions? |
Sample rules: public function rules()
{
return [
[['image'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, jpeg,gif'],
];
} |
@bologer do you mind pasting the result HTML, the browser you use and check if your console has any javascript errors? |
@tonydspaniard, hey. Alright, when I use: 'options' => [
'accept' => 'image/*'
] I get no errors and any file type is uploaded. The same story with 'clientOptions' => [
'acceptFileTypes' => '/(\.|\/)(gif|jpe?g|png)$/i',
'maxFileSize' => 2000000
], No errors or anything, files are just being uploaded. And I noticed that when I try to upload the file that is havier then |
@tonydspaniard furthermore, when I implemented this in my model, I always receive this error: array (size=1)
'image' =>
array (size=1)
0 => string 'Please upload a file.' (length=21) Even though I know for sure that I set This is part of action $model = new UploadedFiles();
$model->scenario = UploadedFiles::SCENARIO_UPLOAD;
$imageFile = UploadedFile::getInstance($model, 'image'); And also, this error does not diplay on the client side, it just fails to I have ...
return [
['image', 'safe'],
[['image'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, jpeg, gif'],
...
];
... |
Strange... if you use the FileUpladAction to your controller should return the validation errors: https://github.com/2amigos/yii2-file-upload-widget/blob/master/src/actions/FileUploadAction.php#L152 |
please check this comment: #116 (comment) |
@tonydspaniard I'm sorry, but how do you run this action that you provided? It seems that it is internal of the plugin. Do I need to override it? Could you please show some minimum example of how to use it? |
Have problem with
'accept' => 'image/*'
should disallow to upload anything that does not matchimage/*
pattern. Everything seems to be clear, however I am able to upload any type of files (e.g. .zip, .rar, any scrpts).What could be the cause of this issue?
The text was updated successfully, but these errors were encountered: