Upload the files.

@param (array)  $files number of files you want to uplaod
@param (string) $root  Server root directory or sub

@since 3.0.0

@return mixed
174370
public function put($files, $root = 'public_html')
    {
        if ($this->isConnected() === true) {
            foreach ($files as $key => $value) {
                ftp_put($this->getConnection(), $server_root.'/'.$value, $value, FTP_ASCII);
            }
        } else {
            return false;
        }
    }
347348
protected function getFiles(array $files)
    {
        $filesEntity = [];

        foreach ($files as $file) {
            $filesEntity[] = new File($file);
        }

        return $filesEntity;
    }
830282
private function mergeAutoload(RootPackageInterface $root)
    {
        if ( ! empty($autoload = $this->getPackage()->getAutoload())) {
            static::unwrapIfNeeded($root, 'setAutoload')
                ->setAutoload(array_merge_recursive(
                    $root->getAutoload(), Util::fixRelativePaths($this->getPath(), $autoload)
                ));
        }
    }
476379
public function deleteFiles($container, $files, $root = '')
    {
        $root = FileUtilities::fixFolderPath($root);
        foreach ($files as $key => $file) {
            try {
                // path is full path, name is relative to root, take either
                $path = array_get($file, 'path');
                $name = array_get($file, 'name');
                if (!empty($path)) {
                    $path = static::removeContainerFromPath($container, $path);
                } elseif (!empty($name)) {
                    $path = $root . $name;
                } else {
                    throw new BadRequestException('No path or name found for file in delete request.');
                }
                if (!empty($path)) {
                    $this->deleteFile($container, $path);
                } else {
                    throw new BadRequestException('No path or name found for file in delete request.');
                }
            } catch (\Exception $ex) {
                // error whole batch here?
                $files[$key]['error'] = ['message' => $ex->getMessage(), 'code' => $ex->getCode()];
            }
        }

        return $files;
    }
156196
protected function upload_from_file( $files, $headers ) {
		if ( empty( $files ) ) {
			return new WP_Error( 'rest_upload_no_data', __( 'No data supplied.' ), array( 'status' => 400 ) );
		}

		// Verify hash, if given.
		if ( ! empty( $headers['content_md5'] ) ) {
			$content_md5 = array_shift( $headers['content_md5'] );
			$expected = trim( $content_md5 );
			$actual = md5_file( $files['file']['tmp_name'] );
			if ( $expected !== $actual ) {
				return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected.' ), array( 'status' => 412 ) );
			}
		}

		// Pass off to WP to handle the actual upload.
		$overrides = array(
			'test_form'   => false,
		);
		// Bypasses is_uploaded_file() when running unit tests.
		if ( defined( 'DIR_TESTDATA' ) && DIR_TESTDATA ) {
			$overrides['action'] = 'wp_handle_mock_upload';
		}

		// Include admin functions to get access to wp_handle_upload().
		require_once ABSPATH . 'wp-admin/includes/admin.php';
		$file = wp_handle_upload( $files['file'], $overrides );

		if ( isset( $file['error'] ) ) {
			return new WP_Error( 'rest_upload_unknown_error', $file['error'], array( 'status' => 500 ) );
		}

		return $file;
	}
954029
public function handleFiles(array $files): array
    {
        $this->removeOldFiles();
        $metadata = [];
        foreach ($files as $file) {
            /**@var $file  UploadedFile */
            if ($file->getError() == UPLOAD_ERR_OK) {
                $originalName = $file->getClientOriginalName();
                $extension = $file->getClientOriginalExtension();
                /**@var $newFile  File */
                if ($newFile = $file->move($this->uploadDir, md5(time().basename($originalName)) . '.' . $extension)) {
                    $metadata[$originalName] = [
                        'host_url'    => $this->hostUrl,
                        'path'        => $newFile->getPathname(),
                        'origin_name' => $originalName,
                        'type'        => $newFile->getMimeType(),
                        'size'        => $newFile->getSize(),
                        'extension'   => $extension
                    ];
                } else {
                    throw new FileUploadException('File upload error');
                }
            }
        }

        return $metadata;
    }
686526
protected function convertUploadedFiles( array $files )
	{
		return array_map( function ( $file )
		{
			if ( is_null( $file ) || ( is_array( $file ) && empty( array_filter( $file ) ) ) )
				return $file;

			return is_array( $file ) ? $this->convertUploadedFiles( $file ) : UploadedFile::createFromBase( $file );
		}, $files );
	}
680362
public function upload($files = '')
    {
        if ('' === $files) {
            $files = $_FILES;
        }
        if (empty($files)) {
            $this->error = '没有上传的文件！';

            return false;
        }
        /* 检测上传根目录 */
        if (!$this->uploader->checkRootPath($this->rootPath)) {
            $this->error = $this->uploader->getError();

            return false;
        }
        /* 检查上传目录 */
        if (!$this->uploader->checkSavePath($this->savePath)) {
            $this->error = $this->uploader->getError();

            return false;
        }
        /* 逐个检测并上传文件 */
        $info = [];
        if (function_exists('finfo_open')) {
            $finfo = finfo_open(FILEINFO_MIME_TYPE);
        }
        // 对上传文件数组信息处理
        $files = $this->dealFiles($files);
        foreach ($files as $key => $file) {
            $file['name'] = strip_tags($file['name']);
            if (!isset($file['key'])) {
                $file['key'] = $key;
            }
            /* 通过扩展获取文件类型，可解决FLASH上传$FILES数组返回文件类型错误的问题 */
            if (isset($finfo)) {
                $file['type'] = finfo_file($finfo, $file['tmp_name']);
            }
            /* 获取上传文件后缀，允许上传无后缀文件 */
            $file['ext'] = pathinfo($file['name'], PATHINFO_EXTENSION);
            /* 文件上传检测 */
            if (!$this->check($file)) {
                continue;
            }
            /* 获取文件hash */
            if ($this->hash) {
                $file['md5'] = md5_file($file['tmp_name']);
                $file['sha1'] = sha1_file($file['tmp_name']);
            }
            /* 调用回调函数检测文件是否存在 */
            if ($this->callback) {
                $data = call_user_func($this->callback, $file);
            }
            if ($this->callback && $data) {
                if (file_exists('.' . $data['path'])) {
                    $info[$key] = $data;
                    continue;
                } elseif ($this->removeTrash) {
                    call_user_func($this->removeTrash, $data); //删除垃圾据
                }
            }
            /* 生成保存文件名 */
            $savename = $this->getSaveName($file);
            if (false == $savename) {
                continue;
            } else {
                $file['savename'] = $savename;
            }
            /* 检测并创建子目录 */
            $subpath = $this->getSubPath($file['name']);
            if (false === $subpath) {
                continue;
            } else {
                $file['savepath'] = $this->savePath . $subpath;
            }
            /* 对图像文件进行严格检测 */
            $ext = strtolower($file['ext']);
            if (in_array($ext, ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf'])) {
                $imginfo = getimagesize($file['tmp_name']);
                if (empty($imginfo) || ('gif' == $ext && empty($imginfo['bits']))) {
                    $this->error = '非法图像文件！';
                    continue;
                }
            }
            /* 保存文件 并记录保存成功的文件 */
            if ($this->uploader->save($file, $this->replace)) {
                unset($file['error'], $file['tmp_name']);
                $info[$key] = $file;
            } else {
                $this->error = $this->uploader->getError();
            }
        }
        if (isset($finfo)) {
            finfo_close($finfo);
        }

        return empty($info) ? false : $info;
    }
1332478
public function upload($files)
    {
        $exception = null;

        //for each client
        foreach ($this->children as $child) {
            $this->logger->info(sprintf('[dizda-backup] Uploading to %s', $child->getName()));

            try {
                //try to upload every file, one at a time
                foreach ($files as $file) {
                    $child->upload($file);
                }
            } catch (\Exception $e) {
                //save the exception for later, there might be other children that are working
                $exception = $e;
            }
        }

        if ($exception) {
            throw $exception;
        }
    }
1340022
public static function upload(String $fileName = 'upload', String $rootDir = UPLOADS_DIR) : Bool
    {
        return Upload::start($fileName, $rootDir);
    }
999080
public function put($uri, array $headers = [], $datas = [], array $files = [])
    {
        return $this->send($uri, InternalRequestInterface::METHOD_PUT, $headers, $datas, $files);
    }
1250536
public function setFiles($files = array())
    {
        if (count($files) === 0) {
            $this->_files = $_FILES;
        } else {
            $this->_files = $files;
        }
        return $this;
    }
251600
public function uploadFilesById($id, $files)
    {
        $crudeName = $this->getCalledClassName();
        $model = $this->getById($id);

        $fileAttrName = $this->getFileAttrName();

        $model = (new CrudeFiles)->upload($model, $crudeName, $files, $fileAttrName);

        return $this->updateById($id, [$fileAttrName => $model->files]);
    }
437345
public function loadFiles($files)
    {
        $files = (array) $files;

        $success = true;
        foreach ($files as $file) {

            $this->loadFile($file);
        }
        return true;
    }
1353391
public function addFiles(array $files)
    {
        $added_files = 0;
        foreach ($files as $localName => $fileName) {
            if (is_null($fileName)) {
                if ($this->zip->addEmptyDir($localName) === false)
                    throw new Exception($this->zip->getStatusString(), $this->zip->status);
            } else {
                if ($this->zip->addFile($fileName, $localName) === false)
                    throw new Exception($this->zip->getStatusString(), $this->zip->status);
                $added_files++;
            }
        }

        // reopen archive to save changes
        $archive_filename = $this->zip->filename;
        $this->zip->close();
        $this->open($archive_filename);

        return $added_files;
    }
1041069
public function createUploadedFilesFromArray(array $files)
    {
        $uploadedFiles = [];

        if (isset($files['tmp_name']) && ! is_array($files['tmp_name'])) {
            $uploadedFiles[] = $this->createUploadedFile(
                $files['tmp_name'],
                $files['size'],
                $files['error'],
                $files['name'],
                $files['type']
            );
        } elseif (isset($files['tmp_name']) && is_array($files['tmp_name'])) {
            foreach ($files['tmp_name'] as $key => $file) {
                $uploadedFiles[] = $this->createUploadedFile(
                    $file,
                    $files['size'][$key],
                    $files['error'][$key],
                    $files['name'][$key],
                    $files['type'][$key]
                );
            }
        } else {
            foreach ($files as $key => $value) {
                $uploadedFiles[$key] = $this->createUploadedFilesFromArray($value);
            }
        }

        return $uploadedFiles;
    }
953179
public function set(array $files)
    {
        if (!empty($files)) {
            foreach ($files as $_file) {
                if (is_array($_file) && isset($_file['file'])) {
                    $this->add(
                        $_file['file'],
                        isset($_file['media']) ? $_file['media'] : '',
                        isset($_file['condition']) ? $_file['condition'] : null
                    );
                } elseif (is_string($_file)) {
                    $this->add($_file);
                }
            }
        }
        return $this;
    }