小编Dan*_*ood的帖子

从php返回dropzone.js的错误

我想从我处理上传的PHP代码中返回一个错误.

目前,如果php上传失败,JS仍然认为它成功了,我认为这与它返回的事实有关.

我试过返回false而不是字符串,但仍然运行this.on('success')函数.

PHP

public function imageUpload(){
    //?heck that we have a file

    if((!empty($_FILES["file"])) && ($_FILES['file']['error'] == 0)) {

      //Check if the file is JPEG image and it's size is less than 350Kb
      $filename = basename($_FILES['file']['name']);
      $ext = substr($filename, strrpos($filename, '.') + 1);

      if (($ext == "jpg") && ($_FILES["file"]["type"] == "image/jpeg") && 
        ($_FILES["file"]["size"] < 3500000)) {

        //Determine the path to which we want to save this file
          $newname = '/home/anglicvw/public_html/newdev/app/templates/default/images/testimages/'.$filename;
          //Check if the file with the same name is already …
Run Code Online (Sandbox Code Playgroud)

javascript php dropzone.js

3
推荐指数
1
解决办法
5280
查看次数

标签 统计

dropzone.js ×1

javascript ×1

php ×1