-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug file remove bug, see detail below... #17
Comments
hexl
changed the title
Bug file remove bug, see detail...
Bug file remove bug, see detail below...
May 11, 2015
Still cannot realize when and how does it happen. |
7 tasks
Ive got same problem, and cant solve it(( {"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 <?= 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('Точно хотите удалить?')}"
],
]);?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is the scenario.
The form with 3 fields(reciver, message, attachments) and a submit button.
Step1, fill the reciver and message field.
Step2, add any file and upload it.
Step3, remove the files uploaded in Step2.
Step4, add another files not added in Step2.
Step5, submit the form data.
Here goes the bug, you will find out that the files you delete in Step2 will display in the submit data and the attachments record will insert into the database.
Why? Because the code FileBehavior method saveUploads() will get all the files list in the specified folder. But the files deleted in Step2 still in the folder.
And my own sugesstion is add an event to the remove method. When user remove the file listed in the widgets, removing it from the temp folder at the same time.
The text was updated successfully, but these errors were encountered: