interface UploadedFileInterface
Provides an interface for uploaded files.
Hierarchy
- interface \Drupal\file\Upload\UploadedFileInterface
 
Expanded class hierarchy of UploadedFileInterface
All classes that implement UploadedFileInterface
2 files declare their use of UploadedFileInterface
- FileUploadHandlerTest.php in core/
modules/ file/ tests/ src/ Kernel/ FileUploadHandlerTest.php  - LegacyFileUploadHandlerTest.php in core/
modules/ file/ tests/ src/ Kernel/ Upload/ LegacyFileUploadHandlerTest.php  
File
- 
              core/
modules/ file/ src/ Upload/ UploadedFileInterface.php, line 11  
Namespace
Drupal\file\UploadView source
interface UploadedFileInterface {
  
  /**
   * Returns the original file name.
   *
   * The file name is extracted from the request that uploaded the file and as
   * such should not be considered a safe value.
   *
   * @return string
   *   The original file name supplied by the client.
   */
  public function getClientOriginalName() : string;
  
  /**
   * Returns whether the file was uploaded successfully.
   *
   * @return bool
   *   TRUE if the file has been uploaded with HTTP and no error occurred.
   *
   * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use
   *   \Drupal\file\Validation\UploadedFileValidatorInterface::validate()
   *   instead.
   * @see https://www.drupal.org/node/3375456
   */
  public function isValid() : bool;
  
  /**
   * Returns an informative upload error message.
   *
   * @return string
   *   The error message regarding a failed upload.
   *
   * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use
   *   \Drupal\file\Validation\UploadedFileValidatorInterface::validate()
   *   instead.
   *
   * @see https://www.drupal.org/node/3375456
   */
  public function getErrorMessage() : string;
  
  /**
   * Returns the upload error code.
   *
   * If the upload was successful, the constant UPLOAD_ERR_OK is returned.
   * Otherwise, one of the other UPLOAD_ERR_XXX constants is returned.
   *
   * @return int
   *   The upload error code.
   *
   * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use
   *   \Drupal\file\Validation\UploadedFileValidatorInterface::validate()
   *   instead.
   *
   * @see https://www.drupal.org/node/3375456
   */
  public function getError() : int;
  
  /**
   * Gets file size.
   *
   * @return int
   *   The filesize in bytes.
   *
   * @see https://www.php.net/manual/en/splfileinfo.getsize.php
   */
  public function getSize() : int;
  
  /**
   * Gets the absolute path to the file.
   *
   * @return string|false
   *   The path to the file, or FALSE if the file does not exist.
   *
   * @see https://php.net/manual/en/splfileinfo.getrealpath.php
   */
  public function getRealPath();
  
  /**
   * Gets the path to the file.
   *
   * @return string
   *   The path to the file.
   *
   * @see https://php.net/manual/en/splfileinfo.getpathname.php
   */
  public function getPathname() : string;
  
  /**
   * Gets the filename.
   *
   * @return string
   *   The filename.
   *
   * @see https://php.net/manual/en/splfileinfo.getfilename.php
   */
  public function getFilename() : string;
  
  /**
   * Validates the uploaded file information.
   *
   * @param \Symfony\Component\Validator\Validator\ValidatorInterface $validator
   *   A validator object.
   * @param array $options
   *   Options to pass to a constraint.
   *
   * @return \Symfony\Component\Validator\ConstraintViolationListInterface
   *   The list of violations.
   */
  public function validate(ValidatorInterface $validator, array $options = []) : ConstraintViolationListInterface;
}
Members
| Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overrides | 
|---|---|---|---|---|---|
| UploadedFileInterface::getClientOriginalName | public | function | Returns the original file name. | 2 | |
| UploadedFileInterface::getError | Deprecated | public | function | Returns the upload error code. | 2 | 
| UploadedFileInterface::getErrorMessage | Deprecated | public | function | Returns an informative upload error message. | 2 | 
| UploadedFileInterface::getFilename | public | function | Gets the filename. | 2 | |
| UploadedFileInterface::getPathname | public | function | Gets the path to the file. | 2 | |
| UploadedFileInterface::getRealPath | public | function | Gets the absolute path to the file. | 2 | |
| UploadedFileInterface::getSize | public | function | Gets file size. | 2 | |
| UploadedFileInterface::isValid | Deprecated | public | function | Returns whether the file was uploaded successfully. | 2 | 
| UploadedFileInterface::validate | public | function | Validates the uploaded file information. | 2 | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.