Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe UploadedFile
+ Graphe d'héritage de UploadedFile:

Fonctions membres publiques

 __construct ($streamOrFile, $size, $errorStatus, $clientFilename=null, $clientMediaType=null)
 
 getStream ()
 
 moveTo ($targetPath)
 
 getSize ()
 
 getError ()
 
 getClientFilename ()
 
 getClientMediaType ()
 

Champs de données

const UPLOAD_ERR_INI_SIZE
 

Fonctions membres privées

 validateActive ()
 

Attributs privés

const ERRORS
 
 $clientFilename
 
 $clientMediaType
 
 $error
 
 $file
 
 $moved = false
 
 $size
 
 $stream
 

Description détaillée

Auteur
Michael Dowling and contributors to guzzlehttp/psr7
Tobias Nyholm tobia.nosp@m.s.ny.nosp@m.holm@.nosp@m.gmai.nosp@m.l.com
Martijn van der Ven marti.nosp@m.jn@v.nosp@m.ander.nosp@m.ven..nosp@m.se

This class should never be extended. See https://github.com/Nyholm/psr7/blob/master/doc/final.md

Documentation des constructeurs et destructeur

◆ __construct()

__construct (   $streamOrFile,
  $size,
  $errorStatus,
  $clientFilename = null,
  $clientMediaType = null 
)
Paramètres
StreamInterface | string | resource$streamOrFile
int$size
int$errorStatus
string | null$clientFilename
string | null$clientMediaType

Références UploadedFile\$clientFilename, UploadedFile\$clientMediaType, UploadedFile\$size, Stream\create(), elseif, et null.

Documentation des fonctions membres

◆ getClientFilename()

getClientFilename ( )

Retrieve the filename sent by the client.

Do not trust the value returned by this method. A client could send a malicious filename with the intention to corrupt or hack your application.

Implementations SHOULD return the value stored in the "name" key of the file in the $_FILES array.

Renvoie
string|null The filename sent by the client or null if none was provided.

Implémente UploadedFileInterface.

Références UploadedFile\$clientFilename.

◆ getClientMediaType()

getClientMediaType ( )

Retrieve the media type sent by the client.

Do not trust the value returned by this method. A client could send a malicious media type with the intention to corrupt or hack your application.

Implementations SHOULD return the value stored in the "type" key of the file in the $_FILES array.

Renvoie
string|null The media type sent by the client or null if none was provided.

Implémente UploadedFileInterface.

Références UploadedFile\$clientMediaType.

◆ getError()

getError ( )

Retrieve the error associated with the uploaded file.

The return value MUST be one of PHP's UPLOAD_ERR_XXX constants.

If the file was uploaded successfully, this method MUST return UPLOAD_ERR_OK.

Implementations SHOULD return the value stored in the "error" key of the file in the $_FILES array.

Voir également
http://php.net/manual/en/features.file-upload.errors.php
Renvoie
int One of PHP's UPLOAD_ERR_XXX constants.

Implémente UploadedFileInterface.

Références UploadedFile\$error.

◆ getSize()

getSize ( )

Retrieve the file size.

Implementations SHOULD return the value stored in the "size" key of the file in the $_FILES array if available, as PHP calculates this based on the actual size transmitted.

Renvoie
int|null The file size in bytes or null if unknown.

Implémente UploadedFileInterface.

Références UploadedFile\$size.

◆ getStream()

getStream ( )

Retrieve a stream representing the uploaded file.

This method MUST return a StreamInterface instance, representing the uploaded file. The purpose of this method is to allow utilizing native PHP stream functionality to manipulate the file upload, such as stream_copy_to_stream() (though the result will need to be decorated in a native PHP stream wrapper to work with such functions).

If the moveTo() method has been called previously, this method MUST raise an exception.

Renvoie
StreamInterface Stream representation of the uploaded file.
Exceptions

Implémente UploadedFileInterface.

Références UploadedFile\$stream, Stream\create(), et UploadedFile\validateActive().

Référencé par UploadedFile\moveTo().

◆ moveTo()

moveTo (   $targetPath)

Move the uploaded file to a new location.

Use this method as an alternative to move_uploaded_file(). This method is guaranteed to work in both SAPI and non-SAPI environments. Implementations must determine which environment they are in, and use the appropriate method (move_uploaded_file(), rename(), or a stream operation) to perform the operation.

$targetPath may be an absolute path, or a relative path. If it is a relative path, resolution should be the same as used by PHP's rename() function.

The original file or stream MUST be removed on completion.

If this method is called more than once, any subsequent calls MUST raise an exception.

When used in an SAPI environment where $_FILES is populated, when writing files via moveTo(), is_uploaded_file() and move_uploaded_file() SHOULD be used to ensure permissions and upload status are verified correctly.

If you wish to move to a stream, use getStream(), as SAPI operations cannot guarantee writing to stream destinations.

Voir également
http://php.net/is_uploaded_file
http://php.net/move_uploaded_file
Paramètres
string$targetPathPath to which to move the uploaded file.
Exceptions

Implémente UploadedFileInterface.

Références UploadedFile\$stream, Stream\create(), UploadedFile\getStream(), null, et UploadedFile\validateActive().

◆ validateActive()

validateActive ( )
private
Exceptions

Référencé par UploadedFile\getStream(), et UploadedFile\moveTo().

Documentation des champs

◆ $clientFilename

$clientFilename
private

◆ $clientMediaType

$clientMediaType
private

◆ $error

$error
private

Référencé par UploadedFile\getError().

◆ $file

$file
private

◆ $moved

$moved = false
private

◆ $size

$size
private

◆ $stream

$stream
private

◆ ERRORS

const ERRORS
private
Valeur initiale :
= [
\UPLOAD_ERR_OK => 1

◆ UPLOAD_ERR_INI_SIZE

const UPLOAD_ERR_INI_SIZE
Valeur initiale :
=> 1,
\UPLOAD_ERR_FORM_SIZE => 1,
\UPLOAD_ERR_PARTIAL => 1,
\UPLOAD_ERR_NO_FILE => 1,
\UPLOAD_ERR_NO_TMP_DIR => 1,
\UPLOAD_ERR_CANT_WRITE => 1,
\UPLOAD_ERR_EXTENSION => 1,
]

La documentation de cette classe a été générée à partir du fichier suivant :