Cannot read property 'removeChild' of null dropzone
<p>I have this code:</p>

<p><strong>CODE JS:</strong></p>

<pre><code>var currentFile = null;
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("div#myDrop", {
    url             : "&lt;?php echo $this-&gt;serverUrl() . '/profile/ajax/dzupload'; ?&gt;",
    paramName       : 'profilepicture',
    acceptedFiles   : "image/*",
    maxFiles        : 1,
    addRemoveLinks  : true,
    init            : function() {

        var fileName = $('#profilePicture').val();
        var mockFile = { name: fileName, size: 12345 };
        this.options.addedfile.call(this, mockFile);
        this.options.thumbnail.call(this, mockFile, "&lt;?php echo $this-&gt;serverUrl().'/public/profile/'.'usr'.$practitionerInfo-&gt;user_id.'/picture/'.$practitionerInfo-&gt;profilepicture ?&gt;");
        currentFile = mockFile;


        this.on("addedfile", function(file) {
            if (currentFile) {
                this.removeFile(currentFile);
            }
            currentFile = file;
        });

        this.on("success", function(file, responseText) {

            $('#profilePicture').attr("value", responseText.filename);

            console.log(responseText );
        });

        this.on("maxfilesexceeded", function(file){
            this.removeFile(file);
            alert("You are not allowed to chose more than 1 file!");
        });

        this.on("removedfile", function (file){
            $.ajax({
                method: 'POST',
                url: '&lt;?php echo $this-&gt;serverUrl() . '/profile/ajax/dzdelete' ?&gt;',
                data: {
                    area    : 'company-profile',
                    name    : $('#profilePicture').attr('value')
                },
                success: function(result){
                    $('#profilePicture').attr("value", '')
                    console.log(result);
                }
            })
        });
    }

});
</code></pre>

<p><strong>ERROR:</strong></p>

<pre><code>Cannot read property 'removeChild' of null
</code></pre>

<p>What causes this error?
How can I solve it?</p>

<p>This error occurs when I get on the Upload function</p>

<p>It has never met anyone with such an error?How can I improve my code so that it only be this error?</p>

<p>Thanks in advance!</p>