使用进度条上传多个文件时出错

时间:2019-09-21 06:00:59

标签: php ajax

我正在使用Ajax使用进度条上传多个选定文件。但是我得到了这个错误-

  <b>Fatal error</b>:  Uncaught Error: Using $this when not in object context in C:\xampp\htdocs\multiple\uploadImages.php:31

我的php代码是-

  if ( $_SERVER['REQUEST_METHOD'] === 'POST' )
        {
            for($i=0;$i<count($_FILES['image']['tmp_name']);$i++)
            {
                $path="image//";

                if(is_uploaded_file($_FILES['image']['tmp_name'][$i]) )
                {

                  $ext = strtolower(pathinfo($_FILES['image']['name'][$i], PATHINFO_EXTENSION));

                      if (in_array($ext, $valid_exts) AND $_FILES['image']['size'][$i] < $max_size)
                      {
                              // unique file path
                              $uid = uniqid();
                              $date = date('Y-m-d-H-i-s');
                              $path = $path ."image_" .$date. '_' . $uid . "." .$ext;

                              $returnJson[]= array("filepath"=>$path);

                              $filename = "image_" . $date . "_" .$uid . "." . $ext;
                              $this->createthumb($i,$filename);

                              if (move_uploaded_file($_FILES['image']['tmp_name'][$i], $path))
                              {

                              }
                              else {
                                $status = 'Upload Fail: Unknown error occurred!';
                              }
                      }
                      else {
                        $status = 'Upload Fail: Unsupported file format or It is too large to upload!';
                      }
                }
                else {
                  $status = 'Upload Fail: File not uploaded!';
                }
            }
          }
        else {
          $status = 'Bad request!';
        }

我的代码中的第31行是-

$this->createthumb($i,$filename); 

,它仅返回一个进度条,但是我需要显示所有文件进度条。

0 个答案:

没有答案
相关问题