如何使用dropzone.js制作简单的文件上传脚本
我的尝试:
的index.php
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="dropzone.css">
<script src="ressources/dropzone.js"></script>
</head>
<body>
<form id="my-awesome-dropzone" action="upload.php" class="dropzone"></form>
</body>
</html>
upload.php (来自here的示例)
$target_dir = "data/";
$target_dir = $target_dir . basename( $_FILES["file"]["name"]);
$uploadOk=1;
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_dir)) {
echo "The file ". basename( $_FILES["file"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
答案 0 :(得分:1)
您没有说明问题所在。但是,这是一个很好的可运行的例子。这应该可以帮到你:
http://runnable.com/UbDApm3qYSEiAADm/drag-and-drop-file-upload-php-for-fileupload
此示例包含您需要运行的所有代码。