请帮助您了解如何将选定图像从dropzone上传到特定目录。这是我的代码:
<div class="dropzone" id="mydropzone">
<div class="dropzone-previews"></div>
</div>
<button type="submit" id="submitbtn">Upload</button>
</div>
<script>
Dropzone.options.mydropzone = {
url:"upload.php",
uploadMultiple: true,
maxFilesize: 2,
maxFiles : 3,
autoDiscover:false,
acceptedFiles: ".png,.jpg,.jpeg",
previewsContainer: '.dropzone-previews',
autoProcessQueue : false,
parallelUploads: 100,
addRemoveLinks: true,
init:function(){
var myDropzone = this;
$("#submitbtn").on('click',function(e) {
e.preventDefault();
myDropzone.processQueue();
});
}
}
</script>
我可以在dropzone中拖动照片,但它不会出现在我的子目录中。这是upload.php上的代码:
session_start();
$ds = DIRECTORY_SEPARATOR;
$upload_dir = './upload_photos';
if (!empty($_FILES)) {
$tempFile = $_FILES['file']['tmp_name'];
$targetPath = dirname(__FILE__).$ds.$upload_dir.$ds;
$targetFile = $targetPath. $_FILES['file']['name'];
move_uploaded_file($tempFile,$targetFile);
}
我该怎么办?