正如https://www.startutorial.com/articles/view/how-to-build-a-file-upload-form-using-dropzonejs-and-php中所述,使用PHP尝试使用Dropzone.js进行图像上传。但是想要在$ targetFile名称中存储图像本地具有的所有文件夹路径。所以尝试将其与javascript结合使用:https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL
关于如何处理这个例子的任何建议都会很好。 Javascript有错误"分配中的左侧无效"
Dropzone.options.my-dropzone = {
var reader = new FileReader();
reader.readAsDataURL(input.files[0]);
maxFilesize: 50, // MB
acceptedFiles: "image/jpg, image/jpeg",
params: { relativePath : reader },
init: function() {
this.on("success", function(file, responseText) {
console.log(responseText);
});
}
};

$ ds = DIRECTORY_SEPARATOR;
$ storeFolder ='图片';
if(!empty($ _ FILES)){
$tempFile = $_FILES['file']['tmp_name'];
$targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds;
$targetFile = $targetPath. $_FILES['file']['name']. "_". $_FILES['file']['relativePath'];
move_uploaded_file($tempFile,$targetFile);
}