0

Using Dropzone, I am not able to get the details of the file passed.

I created two upload pages. The page using an input tag works fine. The page using Dropzone does not.

It will not return any $_FILES information. The dropzone page:

<html>
<head>
<title>Competition Information</title>
<link rel="STYLESHEET" HREF="all_pages.css" TYPE="Text/css">
<link rel="STYLESHEET" HREF="dropzone.css" TYPE="Text/css">
</head>
<body>
    <script src="dropzone.js"></script>
    <p class=PageTitle align=center>Uploading a competition Entry</P>
    <form action="upload_handler.php" class="dropzone" id="my-awesome-dropzone">
        <!-- <script>Dropzone.options.myAwesomeDropzone = {
            paramName: "userfile", // The name that will be used to transfer the file
        };
        </script> -->
        <div class="fallback">
            <input name="file" type="file" multiple >
        </div>
        Enter Name of competitor: <input type=text value="CompName">
        <input type=submit value="Submit Entry">
    </form>
</body>
</html>

The file name is commented out. Just using the default 'file'.

The handler page:

<?php
$uploaddir = 'ups/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
echo $uploadfile;
echo '<br>Tempname is '.$_FILES['file']['tmp_name'];
echo '<pre>';
# if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
#    echo "File is valid, and was successfully uploaded.\n";
#} else {
#    echo "Possible file upload attack!\n";
#}
move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile);

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";
?>

The print_r($_FILES) returns no values from the dropzone page. Any help would be gratefully received - thanks.

  • When you're having trouble, try to reduce things to a [minimal, complete, and verifiable example](https://stackoverflow.com/help/mcve). In this case, that could mean a) remove the commented out `script` in the middle of the form. b) Remove your competitor name input - [the super-simple example](https://www.dropzonejs.com/#usage) right at the top of the docs has no other form inputs. c) Remove the submit button (see b). d) Remove the fallback (see b). Try those in turn until you get it working. Then try to work out why what you removed matters. – Don't Panic Jul 06 '20 at 00:47
  • If you want to upload when you click the button, instead of when you drop a file as Dropzone does automatically, and if you want to include your other form inputs, [here's an example of how to do that](https://stackoverflow.com/questions/46728205/dropzone-submit-button-on-upload/46732882#46732882). – Don't Panic Jul 06 '20 at 00:48

0 Answers0