Dropzone JS "Server responded with 0 code"

I'm working with dropzone js and I'm having an issue where in some computers dropzone doesn't make anything. Here's what I have:

HTML:

<form action="acciones.php?accion=subirImagenes" class="dropzone" id="my-awesome-dropzone">
                        
</form>

Dropzone js options:

      url: null,
      method: "post",
      withCredentials: false,
      timeout: 30000,
      parallelUploads: 2,
      uploadMultiple: false,
      maxFilesize: 256,
      paramName: "file",
      createImageThumbnails: true,
      maxThumbnailFilesize: 10,
      thumbnailWidth: 120,
      thumbnailHeight: 120,
      thumbnailMethod: 'crop',
      resizeWidth: null,
      resizeHeight: null,
      resizeMimeType: null,
      resizeQuality: 0.8,
      resizeMethod: 'contain',
      filesizeBase: 1000,
      maxFiles: null,
      params: {},
      headers: null,
      clickable: true,
      ignoreHiddenFiles: true,
      acceptedFiles: null,
      acceptedMimeTypes: null,
      autoProcessQueue: true,
      autoQueue: true,
      addRemoveLinks: false,
      previewsContainer: null,
      hiddenInputContainer: "body",
      capture: null,
      renameFilename: null,
      forceFallback: false

I compared it on 5 computers with same web browser, and just works in my computer and another one. The strange thing is that when I open console on the other computers that aren't working, there is no http request, not even an attemp on looking for it. Just the message on view that says "Server responded with 0 code"

I don't know what's going wrong, why it works just on some computers...

 UPDATE

It seems to be something about the headers, but I don't know which ones should I include on "headers" dropzone option.

Upvotes: 2

Views: 7098

Answers (2)

ShP
ShP

Reputation: 1143

I had the same issue that I successfully resoled by adjusting the Access-Control-Allow-Headers on my API (server side).

So the easiest solution is to run the Fiddler, or just Firefox Network Inspector (any request \ response monitor will do the job), and monitor the raw request headers, and compare with response Access-Control-Allow-Headers headers.

In my case I was missing Cache-Control and X-Requested-With, but you make sure that you also have Content-Type as well.

Check this https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Upvotes: 1

Xavier J
Xavier J

Reputation: 4626

You have to create a server-side method to handle the upload. Dropzone.js only handles the stuff going on on the client side. If you have no server side method, you'll continue to get the error message.

Upvotes: 0

Related Questions