dolibarr 18.0.6
FileUpload Class Reference

This class is used to manage file upload using ajax. More...

Public Member Functions

 __construct ($options=null, $fk_element=null, $element=null)
 Constructor.
 
 get ()
 Output data.
 
 post ()
 Output data.
 
 delete ()
 Delete uploaded file.
 

Protected Member Functions

 getFullUrl ()
 Return full URL.
 
 setFileDeleteUrl ($file)
 Set delete url.
 
 getFileObject ($file_name)
 getFileObject
 
 getFileObjects ()
 getFileObjects
 
 createScaledImage ($file_name, $options)
 Create thumbs of a file uploaded.
 
 validate ($uploaded_file, $file, $error, $index)
 Enter description here ...
 
 upcountNameCallback ($matches)
 Enter description here ...
 
 upcountName ($name)
 Enter description here ...
 
 trimFileName ($name, $type, $index)
 trimFileName
 
 handleFileUpload ($uploaded_file, $name, $size, $type, $error, $index)
 handleFileUpload.
 

Detailed Description

This class is used to manage file upload using ajax.

Definition at line 31 of file fileupload.class.php.

Constructor & Destructor Documentation

◆ __construct()

FileUpload::__construct ( $options = null,
$fk_element = null,
$element = null )

Constructor.

This set ->$options

Parameters
array$optionsOptions array
int$fk_elementID of element
string$elementCode of element

Definition at line 45 of file fileupload.class.php.

References dol_include_once(), dol_sanitizeFileName(), fetchObjectByElement(), get_exdir(), getElementProperties(), and setEventMessage().

Member Function Documentation

◆ createScaledImage()

FileUpload::createScaledImage ( $file_name,
$options )
protected

Create thumbs of a file uploaded.

Parameters
string$file_nameFilename
string$optionsis array('max_width', 'max_height')
Returns
boolean

Definition at line 254 of file fileupload.class.php.

References dol_mkdir(), and vignette().

Referenced by handleFileUpload().

◆ delete()

FileUpload::delete ( )

Delete uploaded file.

Returns
int

Definition at line 559 of file fileupload.class.php.

◆ get()

FileUpload::get ( )

Output data.

Returns
void

Definition at line 469 of file fileupload.class.php.

References getFileObject(), and getFileObjects().

◆ getFileObject()

FileUpload::getFileObject ( $file_name)
protected

getFileObject

Parameters
string$file_nameFilename
Returns
stdClass|null

Definition at line 212 of file fileupload.class.php.

References dol_mimetype(), and setFileDeleteUrl().

Referenced by get().

◆ getFileObjects()

FileUpload::getFileObjects ( )
protected

getFileObjects

Returns
array Array of objects

Definition at line 242 of file fileupload.class.php.

Referenced by get(), and validate().

◆ getFullUrl()

FileUpload::getFullUrl ( )
protected

Return full URL.

Returns
string URL

Definition at line 178 of file fileupload.class.php.

◆ handleFileUpload()

FileUpload::handleFileUpload ( $uploaded_file,
$name,
$size,
$type,
$error,
$index )
protected

handleFileUpload.

Validate data, move the uploaded file then create the thumbs if this is an image.

Parameters
string$uploaded_fileUploade file
string$nameName
int$sizeSize
string$typeType
string$errorError
string$indexIndex
Returns
stdClass|null

Definition at line 408 of file fileupload.class.php.

References createScaledImage(), dol_mimetype(), dol_mkdir(), dol_move_uploaded_file(), setFileDeleteUrl(), trimFileName(), and validate().

Referenced by post().

◆ post()

FileUpload::post ( )

Output data.

Returns
int 0 if OK, nb of error if errors

Definition at line 487 of file fileupload.class.php.

References handleFileUpload().

◆ setFileDeleteUrl()

FileUpload::setFileDeleteUrl ( $file)
protected

Set delete url.

Parameters
object$fileFilename
Returns
void

Definition at line 196 of file fileupload.class.php.

Referenced by getFileObject(), and handleFileUpload().

◆ trimFileName()

FileUpload::trimFileName ( $name,
$type,
$index )
protected

trimFileName

Parameters
string$nameFilename
string$type???
string$index???
Returns
string

Definition at line 377 of file fileupload.class.php.

References upcountName().

Referenced by handleFileUpload().

◆ upcountName()

FileUpload::upcountName ( $name)
protected

Enter description here ...

Parameters
string$name???
Returns
string ???

Definition at line 364 of file fileupload.class.php.

Referenced by trimFileName().

◆ upcountNameCallback()

FileUpload::upcountNameCallback ( $matches)
protected

Enter description here ...

Parameters
int$matches???
Returns
string ???

Definition at line 351 of file fileupload.class.php.

◆ validate()

FileUpload::validate ( $uploaded_file,
$file,
$error,
$index )
protected

Enter description here ...

Parameters
string$uploaded_fileUploade file
object$fileFile
string$errorError
string$indexIndex
Returns
boolean True if OK, False if KO

Definition at line 292 of file fileupload.class.php.

References getFileObjects().

Referenced by handleFileUpload().


The documentation for this class was generated from the following file: