I use the dropzonejs library to download files. I need to create the file discussdesk.xlsx .

But when I start using library options, it is not created.

Where is the mistake?

Actually, the code itself:

  <?php $uploadedStatus = 0; if (!empty($_FILES)) { var_dump($_FILES); die(); //if there was an error uploading the file if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { if (file_exists($_FILES["file"]["name"])) { unlink($_FILES["file"]["name"]); } $storagename = "discussdesk.xlsx"; move_uploaded_file($_FILES["file"]["tmp_name"], $storagename); $uploadedStatus = 1; } } ?> <html> <head> <title>php excel to mysql</title> <meta name="description" content="php excel to mysql"/> <meta name="keywords" content="PHPExcel"/> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <script src="dropzone/dropzone.js"></script> <link rel="stylesheet" href="dropzone/dropzone.css"> </head> <body> <section> <table width="600"> <tr> <td colspan="2" style="font:bold 21px arial; text-align:center; border-bottom:1px solid #eee; padding:5px 0 10px 0;">Download an Excel database</td> </tr> <tr> <td colspan="2" style="border-bottom:1px solid #eee; padding:5px;" > <div class="target" style="visibility: hidden;"> <b>File Uploaded<b/><b>Do you want to upload the data <a href='pourintobase.php'>Click Here</a><b/> </div> <div class="targetworks" style="visibility: visible;"><b><?php print "Hello Mister, ".$userdata[0]['user_login'].". Successfully works!";?><b/></div> </td> </tr> <tr> <td width="20%" style="font:bold 12px tahoma, arial, sans-serif; text-align:right; border-bottom:1px solid #eee; padding:5px 10px 5px 0px; border-right:1px solid #eee;">Select file</td> <td width="80%" height="196px" style="border-bottom:1px solid #eee; border:dotted; border-color:#207347; padding:0px; margin: 0px;"> <div id="dropzone"><form id="filedrop" action="<?php echo $_SERVER["PHP_SELF"]; ?>" class= "dropzone"><div class="dz-message"> Drop files here or click to upload. </div></form></div> </td> </tr> <tr> <td colspan="2"> <form action="<?php echo $_SERVER["PHP_SELF"];?>" method="post"> <input type="submit" name="exit" value="exit"/> </form> </td> </tr> </table> </section> <script> jQuery(document).ready(function(e) { Dropzone.options.filedrop = { maxFilesize: 40, // MB acceptedFiles: ".xlsx", accept: function (done) { $("div.target").effect("slide", "slow").css("visibility", "visible"); $("div.targetworks").effect("puff", "slow").css("visibility", "hidden"); } } }); </script> </body> </html> 

even if the condition does not fall.

    1 answer 1

    If this file already exists somewhere, try this:

     var existingFile = { name: 'discussdesk.xlsx', size: file.src_size, file_id: file.id, url: file.url}; Dropzone.emit("addedfile", existingFile); Dropzone.emit("complete", existingFile); Dropzone.emit("thumbnail", existingFile, file.url); 

    I like to drop previously saved files in a dropzone like this after reloading the page.