uploads.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. use yii\helpers\Html;
  3. use dosamigos\fileupload\FileUpload;
  4. use dosamigos\fileupload\FileUploadUI;
  5. /** @var yii\web\View $this */
  6. /** @var app\models\Page $model */
  7. $this->title = 'Create Pages';
  8. $this->params['breadcrumbs'][] = ['label' => 'Docs', 'url' => ['index']];
  9. $this->params['breadcrumbs'][] = $this->title;
  10. $cat = Yii::$app->request->get('cat', '');
  11. ?>
  12. <div class="page-create">
  13. <?php
  14. // with UI
  15. ?>
  16. <?= FileUploadUI::widget([
  17. 'model' => $model,
  18. 'attribute' => 'file',
  19. 'url' => ['docsupload', 'id' => 0, 'cat'=>$cat],
  20. 'gallery' => false,
  21. 'fieldOptions' => [
  22. 'accept' => '*'
  23. ],
  24. 'clientOptions' => [
  25. 'limitConcurrentUploads' => 3,
  26. 'disableImageMetaDataLoad' => true
  27. ],
  28. // ...
  29. 'clientEvents' => [
  30. 'fileuploaddone' => 'function(e, data) {
  31. // console.log(e);
  32. // console.log(data);
  33. console.log(data.context);
  34. console.log(data);
  35. setTimeout(() => {
  36. // $(data.context[0]).removeClass("show");
  37. $(data.context[0]).css("display","none");
  38. }, 4000);
  39. e.preventDefault();
  40. }',
  41. 'fileuploadfail' => 'function(e, data) {
  42. // console.log(e);
  43. // console.log(data);
  44. e.preventDefault();
  45. }',
  46. 'fileuploadchange' => 'function(e, data) {
  47. // console.log(e);
  48. // console.log(data);
  49. setTimeout(() => {
  50. $(".template-upload").removeClass("fade");
  51. }, 500);
  52. //e.preventDefault();
  53. }',
  54. 'fileuploadstart' => 'function(e, data) {
  55. $(".fileupload-progress").removeClass("fade");
  56. e.preventDefault();
  57. }',
  58. ],
  59. ]); ?>
  60. </div>