Comments (2)
Still cannot realize when and how does it happen.
from yii2-attachments.
Ive got same problem, and cant solve it((
after upload contorller returns only file name
I overload method actionUpload in FileController to return json data
{"initialPreviewConfig":[{"url":"/attachments/file/delete-temp?filename=pattern1.jpg","key":""}],"append":true}
but its not fixed problem.
Checked another project with native use of kartik\file\FileInput, everything works with json data above.
Some screenshots
Your module init:
<?= AttachmentsInput::widget([
'id' => Html::getInputId($model, 'files'), // Optional
'model' => $model,
'options' => [ // Options of the Kartik's FileInput widget
'multiple' => true, // If you want to allow multiple upload, default to false
'accept' => 'image/*',
],
'pluginOptions' => [ // Plugin options of the Kartik's FileInput widget
// 'maxFileCount' => 0,
'initialPreviewAsData' => true,
'overwriteInitial' => true,
'showClose' => false,
'showCaption' => false,
'showUpload' => true,
'uploadAsync' => true,
'browseLabel' => '',
'removeLabel' => '',
'browseIcon' => '<i class="glyphicon glyphicon-folder-open"></i>',
'removeIcon' => '<i class="glyphicon glyphicon-remove"></i>',
'removeTitle' => 'Cancel or reset changes',
// 'elErrorContainer' => '#appeal-images-errors',
// 'msgErrorClass' => 'alert alert-block alert-danger',
'defaultPreviewContent' => '<img src="/upload_image.png" alt="Фото проблемы" style="width: 160px">',
'layoutTemplates' => "{main2: '{preview} ' + btnCust + ' {remove} {browse}'}",
'allowedFileExtensions' => ["jpg", "png", "gif", "jpeg", 'svg'],
]
]) ?>
And working project
<?=$form->field($model::photosModel(), 'uploadPhotos', ['template'=>"{label}\n{hint}\n{error}\n{input}\n"])
->hint($_photosHint, ['class'=>'alert alert-warning'])
->label(false)
->widget(FileInput::className(), [
'name' => 'uploadPhotos[]',
'options' => [
'multiple' => true,
'accept' => 'image/jpg, image/png',
],
'pluginOptions' => [
'initialPreview' => $model->photosInitialPreview(),
'uploadUrl' => \yii\helpers\Url::to(['/items/upload']),
'uploadAsync' => true,
'overwriteInitial' => false,
'initialPreviewConfig' => $model->photosInitialPreviewConfig(),
'uploadExtraData' => ['id_items'=>$model->primaryKey],
'maxImageWidth' => 1600,
'maxImageHeight' => 1600,
],
'pluginEvents' => [
'filepredelete' => "function(){ return !confirm('Точно хотите удалить?')}"
],
]);?>
from yii2-attachments.
Related Issues (20)
- Thumbnail style view HOT 3
- How to add dynamic location
- when uploaded file has no extension upload failes (type cannot be empty in model)
- array_slice() expects parameter 1 to be array, object given HOT 4
- Problem when using AR in console HOT 1
- AttachmentsInput and AttachmentsTable do not display
- Configuration of migration HOT 1
- Failed to hide initialPreview
- Event afterUpload
- Yii2 attachment module not found
- How to get the url to the already uploaded image HOT 1
- How to copy (duplicate) attachments from one model to another?
- Possibility of attaching files to the model with possible errors
- Open file instead of download HOT 1
- Replace saving short model name with full
- Problem with drag & drop with new version of fileinput
- Calling multiple saves of the model on same request raises Exception
- 404 page not found .....?r=attachments%2Ffile%2Fupload
- Latest version requires php 8.0 functionality
- Lastest Version Need Bootstrap5 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-attachments.