因此,在本地运行文件时,它可以按照我的要求运行,但是当我在实际网站上运行时,它不会以相同的方式执行。
Dropzone.prototype.defaultOptions = {
url: null,
method: "post",
withCredentials: false,
parallelUploads: 2,
uploadMultiple: false,
maxFilesize: 3,
paramName: "file",
createImageThumbnails: true,
maxThumbnailFilesize: 10,
thumbnailWidth: 100,
thumbnailHeight: 100,
maxFiles: 6,
params: {},
clickable: true,
ignoreHiddenFiles: true,
acceptedFiles: "image/jpeg",
acceptedMimeTypes: null,
autoProcessQueue: true,
addRemoveLinks: false,
previewsContainer: null,
dictDefaultMessage: "Drop files here to upload",
dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
dictFileTooBig: "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",
dictInvalidFileType: "You can't upload files of this type.",
dictResponseError: "Server responded with {{statusCode}} code.",
dictCancelUpload: "Cancel upload",
dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",
dictRemoveFile: "Remove file",
dictRemoveFileConfirmation: null,
dictMaxFilesExceeded: "You can not upload any more files.",
...
这些工作在本地网站上,但似乎不适用于实际网站。它只能识别jpeg的自定义文件以及3Mb最大值。
<?php
if ($_GET['audit_id']) {
$id = $_GET['audit_id'];
$ds = DIRECTORY_SEPARATOR; //1
$storeFolder = 'uploads'; //2
//count how many files are in director
$directory = 'uploads/';
$files = glob($directory . 'audit'.$id.'_image*.jpg');
$count = 0;
if ($files !== false) {
$count = count($files) + 1;
}
if (!empty($_FILES)) {
$tempFile = $_FILES['file']['tmp_name']; //3
$rename = explode('.', $_FILES['file']['name']);
$nameString = 'audit'.$id.'_image'.$count.'.'.$rename[1];
//only allow certain image files
$allowed = array( 'jpg'
);
if (in_array($rename[1], $allowed)) {
$targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds; //4
$targetFile = $targetPath. $nameString; //5
move_uploaded_file($tempFile,$targetFile); //6
}
}
} else {
echo 'fatal error.';
}
?>
它无法识别所设置的选项,也不会在实际网站上传。这可能是由于dropzone.js无法正常阅读..?
现在最大限度地提高文件权限,以确保它正常工作,所以我无法看到它。
答案 0 :(得分:0)
原来只需要几个小时才能真正更新,上面的代码工作正常。