简体   繁体   中英

DropZone.JS not working on live site

So when running the files locally it works how I want it to, however when I run it on the live site it doesn't perform in the same way.

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.",
    ...

These work on the local site, but don't appear to work on the live site. It's not recognizing the custom files for jpeg only as well as 3Mb maximum.

<?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.';
}
?>

It doesn't recognize the options set, and doesn't upload on the live site. This could be due to the dropzone.js not reading properly..?

File permissions are maxed out for now to make sure it's working so I can't see it being that.

事实证明,只需要几个小时即可进行真正的更新,以上代码可以正常工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM