最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Dropzone js not working without form - Stack Overflow

programmeradmin1浏览0评论

How can I use dropzone without using the class in the form.

I basically want to have a div inside a form and call class="dropzone" in that div. But it doesn't seems to work.

Here is my code below:

<!DOCTYPE html>
<html lang="en">
    <head>
    <title></title>
    <link rel="stylesheet" href="css/basic.css" />
    <link rel="stylesheet" href="css/dropzone.css"/>
    <script src="dropzone.min.js"></script>
    <script type="text/javascript">
        var myDropzone = new Dropzone("div#myId", { url: "file-upload"})
    </script>

    <body>
        <form action="upload.php">
            <input type="text">
            <div id="myId" class="dropzone"></div>
        </form>
    </body>
</html>

How can I use dropzone without using the class in the form.

I basically want to have a div inside a form and call class="dropzone" in that div. But it doesn't seems to work.

Here is my code below:

<!DOCTYPE html>
<html lang="en">
    <head>
    <title></title>
    <link rel="stylesheet" href="css/basic.css" />
    <link rel="stylesheet" href="css/dropzone.css"/>
    <script src="dropzone.min.js"></script>
    <script type="text/javascript">
        var myDropzone = new Dropzone("div#myId", { url: "file-upload"})
    </script>

    <body>
        <form action="upload.php">
            <input type="text">
            <div id="myId" class="dropzone"></div>
        </form>
    </body>
</html>
Share edited Nov 14, 2013 at 21:06 tadman 212k23 gold badges236 silver badges265 bronze badges asked Apr 24, 2013 at 9:47 Ashish PrasadAshish Prasad 231 gold badge1 silver badge4 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

Initiate .ready event when DOM ready and use like this.

<!DOCTYPE html>
<html lang="en">
    <head>
    <title></title>
    <link rel="stylesheet" href="css/basic.css" />
    <link rel="stylesheet" href="css/dropzone.css"/>
    <script src="dropzone.min.js"></script>
    <script type="text/javascript">
        jQuery(document).ready(function() 
        {
            var myDropzone = new Dropzone("div#myId", { url: "file-upload"});
        });
    </script>

    <body>
        <form action="upload.php">
            <input type="text">
            <div id="myId" class="dropzone"></div>
        </form>
    </body>
</html>

your url parameter is not pointing to any valid php file. I believe your code should be thus

<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<link rel="stylesheet" href="css/basic.css" />
<link rel="stylesheet" href="css/dropzone.css"/>
<script src="dropzone.min.js"></script>
<script type="text/javascript">
    var myDropzone = new Dropzone("div#myId", { url: "upload.php"}) //according to your forms action
</script>

<body>
    <form action="upload.php">
        <input type="text">
        <div id="myId" class="dropzone"></div>
    </form>
</body>

发布评论

评论列表(0)

  1. 暂无评论