Dropzone在本地主机上工作正常,在远程服务器上抛出错误

Dropzone working properly on localhost, throws error on remote server

本文关键字:服务器 错误 出错 主机 工作 Dropzone      更新时间:2023-09-26

我已经配置了dropzone并在我的本地主机(这是一台Windows机器)上进行了测试。一切工作正常,文件正在上传和处理适当的Laravel。问题是,同样的事情没有发生在我的web服务器上。代码在两台机器上是相同的。在windows上,div中的下拉区是正确显示的(文本说拖放文件),但在web服务器上,文本不显示,我不能点击区域。

Chrome开发工具说:Uncaught error: No URL provided

,即使我已经配置了url。我在谷歌上搜索了这个错误,发现禁用自动发现应该可以解决这个问题。我试过了,但它甚至在本地服务器上也不起作用。

这是我的dropzone选项文件:

Dropzone.options.editFilijalaDropzone = { // The camelized version of the ID of the form element
  // The configuration we've talked about above
  autoProcessQueue: false,
  uploadMultiple: true,
  parallelUploads: 10,
  maxFiles: 10,
  addRemoveLinks: false,
  acceptedFiles: '.jpeg,.jpg,.png,.gif',
  url: "/uploadNew/filijale/filijala/" + document.getElementById('filijala_hidden').value,
  headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
  // The setting up of the dropzone
  init: function() {
    var myDropzone = this;
    // First change the button to actually tell Dropzone to process the queue.
    var element = document.getElementById('edit_filijala_submit');
    var form = document.getElementById('edit_filijala_form');
    element.addEventListener("click", function(e) {
      // Make sure that the form isn't actually being sent.
      e.preventDefault();
      e.stopPropagation();
      myDropzone.processQueue();
    });
    // Listen to the sendingmultiple event. In this case, it's the sendingmultiple event instead
    // of the sending event because uploadMultiple is set to true.
    this.on("sendingmultiple", function() {
      // Gets triggered when the form is actually being sent.
      // Hide the success button or the complete form.
    });
    this.on("successmultiple", function(files, response) {
      // Gets triggered when the files have successfully been sent.
      // Redirect user or notify of success.
            form.submit();
    });
    this.on("errormultiple", function(files, response) {
      // Gets triggered when there was an error sending the files.
      // Maybe show form again, and notify user of error
    });
  }
}

问题的HTML是:

<h1>Ažuriranje filijale za firmu: {{ $firma->naziv }}</h1>
    <!-- if there are creation errors, they will show here -->
    {{ HTML::ul($errors->all()) }}
        {!! Form::model($filijala, [
            'method' => 'PUT',
            'action' => array('FilijalaAdminController@update', $firma->id, $filijala->id),
            'id' => 'edit_filijala_form'
    ]) !!}

    <div class="form-group">
        {!! Form::label('Naziv firme', 'Naziv firme') !!}
        {!! Form::text('naziv_firme', $firma->naziv, array('class' => 'form-control', 'readonly')) !!}
    </div>
        <div class="form-group">
        {!! Form::hidden('filijala_hidden', $filijala->id, array('class' => 'form-control', 'id' => 'filijala_hidden')) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Adresa filijale', 'Adresa filijale') !!}
        {!! Form::text('adresa', Input::old('adresa'), array('class' => 'form-control')) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Telefon', 'Telefon') !!}
        {!! Form::text('telefon', Input::old('telefon'), array('class' => 'form-control')) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Email', 'Email') !!}
        {!! Form::text('email', Input::old('email'), array('class' => 'form-control')) !!}
    </div>
        <div class="form-group">
            {!! Form::label('Uklanjanje slika', 'Uklanjanje slika') !!}
            <div class="row">
                @foreach($slike as $slika)
                    <div class="col-lg-3 col-md-4 col-xs-6 thumb">
                            <a <?php echo 'href="#imageOverlay' . $slika->id . '"'; ?> data-toggle="drop-panel" class="thumbnail">
                                <img <?php echo 'id="image' . $slika->id . '"'; ?> class="img-responsive" src="{{ $slika->url }}">
                            </a>
                            <div <?php echo 'id="imageOverlay' . $slika->id . '"'; ?> class="cap-overlay show">
                                <div class="content">
                                    <a href="javascript:obrisiSliku('{{ $slika->id }}', 'filijale')" class="button small"><h5>Obriši sliku</h5></a>
                                </div>
                            </div>
                    </div>
                @endforeach
            </div>
        </div>
        <div class="form-group">
                {!! $slike->render() !!}
        </div>
        <div class="form-group">
            {!! Form::label('Dodavanje slika', 'Dodavanje slika') !!}
            <div class="dropzone" id="edit_filijala_dropzone">
            </div>
        </div>
    <div class="form-group">
        {!! Form::submit('Ažuriraj filijalu', array('id' => 'edit_filijala_submit')) !!}
    </div>
    {!! Form::close() !!}

服务器是CentOS linux机器

编辑:

生成的HTML:
<html><head>
    <title>Ažuriranje filijale</title>
    <meta name="csrf-token" content="9dglsQuYuxZEcbko7sCwj8PMzQgbwFlpnfwlT5Gr">
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/dropzone.css">
  <link rel="stylesheet" href="/css/thumbnail-gallery.css">
  <style>
    .cap-overlay .button { margin-top:10px}
    .cap-overlay{width: 100%; color:#fff; background: rgba(0, 0, 0, 0.43);left:0;padding:12px; line-height: 1.4em;font-size:14px}
    .cap-overlay h5 {color:#fff;}
    a[data-toggle="drop-panel"] {display: block;}
  </style>
<style type="text/css"></style></head>
<body>
<div class="container">
<nav class="navbar navbar-inverse">
    <ul class="nav navbar-nav">
                    <li><a href="http://5.189.145.111/admin_firme/2">Sve filijale za firmu</a></li>
            <li><a href="http://5.189.145.111/admin_firme/2/filijale/create">Nova filijala</a>
            </li></ul>
</nav>


<h1>Ažuriranje filijale za firmu: Kaymo PROPO LIST d.o.o                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              </h1>
    <!-- if there are creation errors, they will show here -->
    
        <form method="POST" action="http://5.189.145.111/admin_firme/2/filijale/8" accept-charset="UTF-8" id="edit_filijala_form"><input name="_method" type="hidden" value="PUT"><input name="_token" type="hidden" value="9dglsQuYuxZEcbko7sCwj8PMzQgbwFlpnfwlT5Gr">

    <div class="form-group">
        <label for="Naziv firme">Naziv firme</label>
        <input class="form-control" readonly="readonly" name="naziv_firme" type="text" value="Company X                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ">
    </div>
        <div class="form-group">
        <input class="form-control" id="filijala_hidden" name="filijala_hidden" type="hidden" value="8">
    </div>
    <div class="form-group">
        <label for="Adresa filijale">Adresa filijale</label>
        <input class="form-control" name="adresa" type="text" value="dsasad                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ">
    </div>
    <div class="form-group">
        <label for="Telefon">Telefon</label>
        <input class="form-control" name="telefon" type="text" value="033 256 987                                                                                         ">
    </div>
    <div class="form-group">
        <label for="Email">Email</label>
        <input class="form-control" name="email" type="text" value="                                                                                 ">
    </div>
        <div class="form-group">
            <label for="Uklanjanje slika">Uklanjanje slika</label>
            <div class="row">
                                    <div class="col-lg-3 col-md-4 col-xs-6 thumb">
                            <div class="drop-panel" style="position: relative; overflow: hidden; display: block; padding: 2px;"><a href="#imageOverlay22" data-toggle="drop-panel" class="thumbnail">
                                <img id="image22" class="img-responsive" src="'image'filijale'192971848455d4d775787cb4.79487595.jpg">
                            </a><div id="imageOverlay22" class="cap-overlay show" style="display: block; width: 345px; height: 321px; position: absolute; z-index: 3; overflow: hidden; left: 0px; top: -321px;">
                                <div class="content">
                                    <a href="javascript:obrisiSliku('22', 'filijale')" class="button small"><h5>Obriši sliku</h5></a>
                                </div>
                            </div></div>
                            
                    </div>
                            </div>
        </div>
        <div class="form-group">
                
        </div>
        <div class="form-group">
            <label for="Dodavanje slika">Dodavanje slika</label>
            <div class="dropzone" id="edit_filijala_dropzone">
            </div>
        </div>
    <div class="form-group">
        <input id="edit_filijala_submit" type="submit" value="Ažuriraj filijalu">
    </div>
    </form>


</div>
    <script src="/js/jquery.js"></script>
  <script src="/js/jquery.hcaptions.js"></script>
  <script src="/js/slike_akcije.js"></script>
    <script src="/js/dropzone.js"></script>
    <script src="/js/dropzone_options.js"></script>
  <script>
    $(window).load(function () {
      $('[data-toggle=drop-panel]').hcaptions();
    });
  </script>

</body></html>

在设置选项前添加这一行

Dropzone.autoDiscover = false;