include/upload_file.php
\UploadFile
- Api
- Manage uploaded files
Properties
array
$filesError= 'array(
UPLOAD_ERR_OK => 'UPLOAD_ERR_OK - There is no error, the file uploaded with success.',
UPLOAD_ERR_INI_SIZE => 'UPLOAD_ERR_INI_SIZE - The uploaded file exceeds the upload_max_filesize directive in php.ini.',
UPLOAD_ERR_FORM_SIZE => 'UPLOAD_ERR_FORM_SIZE - The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
UPLOAD_ERR_PARTIAL => 'UPLOAD_ERR_PARTIAL - The uploaded file was only partially uploaded.',
UPLOAD_ERR_NO_FILE => 'UPLOAD_ERR_NO_FILE - No file was uploaded.',
5 => 'UNKNOWN ERROR',
UPLOAD_ERR_NO_TMP_DIR => 'UPLOAD_ERR_NO_TMP_DIR - Missing a temporary folder.',
UPLOAD_ERR_CANT_WRITE => 'UPLOAD_ERR_CANT_WRITE - Failed to write file to disk.',
UPLOAD_ERR_EXTENSION => 'UPLOAD_ERR_EXTENSION - A PHP extension stopped the file upload.',
)'
Upload errors
array(
UPLOAD_ERR_OK => 'UPLOAD_ERR_OK - There is no error, the file uploaded with success.',
UPLOAD_ERR_INI_SIZE => 'UPLOAD_ERR_INI_SIZE - The uploaded file exceeds the upload_max_filesize directive in php.ini.',
UPLOAD_ERR_FORM_SIZE => 'UPLOAD_ERR_FORM_SIZE - The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
UPLOAD_ERR_PARTIAL => 'UPLOAD_ERR_PARTIAL - The uploaded file was only partially uploaded.',
UPLOAD_ERR_NO_FILE => 'UPLOAD_ERR_NO_FILE - No file was uploaded.',
5 => 'UNKNOWN ERROR',
UPLOAD_ERR_NO_TMP_DIR => 'UPLOAD_ERR_NO_TMP_DIR - Missing a temporary folder.',
UPLOAD_ERR_CANT_WRITE => 'UPLOAD_ERR_CANT_WRITE - Failed to write file to disk.',
UPLOAD_ERR_EXTENSION => 'UPLOAD_ERR_EXTENSION - A PHP extension stopped the file upload.',
)
Details- Type
- array
Methods
UploadFile(
string $field_name
=
''
)
:
void
Create upload file handler
Name | Type | Description |
---|---|---|
$field_name | string | Form field name |
confirm_upload(
)
:
bool
standard PHP file-upload security measures. all variables accessed in a global context
Type | Description |
---|---|
bool | True on success |
create_stored_filename(
)
:
string
creates a file's name for preparation for saving
Type | Description |
---|---|
string |
duplicate_file(
string $old_id, string $new_id, string $file_name
)
:
void
duplicates an already uploaded file in the filesystem.
Name | Type | Description |
---|---|---|
$old_id | string | old_id ID of original note |
$new_id | string | new_id ID of new (copied) note |
$file_name | string | filename Filename of file (deprecated) |
final_move(
string $bean_id
)
:
bool
moves uploaded temp file to permanent save location
Name | Type | Description |
---|---|---|
$bean_id | string | bean_id ID of parent bean |
Type | Description |
---|---|
bool | True on success |
getMime(
array $_FILES_element
)
:
string
Get MIME type for uploaded file
Name | Type | Description |
---|---|---|
$_FILES_element | array | $_FILES element required |
Type | Description |
---|---|
string | MIME type |
getMimeSoap(
string $filename
)
:
string
Guess MIME type for file
Name | Type | Description |
---|---|---|
$filename | string |
Type | Description |
---|---|
string | MIME type |
get_file_path(
string $stored_file_name, string $bean_id, $skip_rename
=
false
)
:
string
builds a URL path for an anchor tag
Name | Type | Description |
---|---|---|
$stored_file_name | string | stored_file_name File name in filesystem |
$bean_id | string | bean_id note bean ID |
$skip_rename |
Type | Description |
---|---|
string | path with file name |
get_upload_error(
)
:
string
Get upload error from system
Type | Description |
---|---|
string | upload error |
get_upload_path(
string $bean_id
)
:
string
returns the path with file name to save an uploaded file
Name | Type | Description |
---|---|---|
$bean_id | string | bean_id ID of the parent bean |
Type | Description |
---|---|
string |
get_upload_url(
\SugarBean $document, string $type
=
null
)
:
void
Get URL of the uploaded file related to the document
Name | Type | Description |
---|---|---|
$document | \SugarBean | |
$type | string | Type of the document, if different from $document |
get_url(
string $stored_file_name, string $bean_id
)
:
string
Get URL for a document
Name | Type | Description |
---|---|---|
$stored_file_name | string | stored_file_name File name in filesystem |
$bean_id | string | bean_id note bean ID |
Type | Description |
---|---|
string | path with file name |
- Deprecated
realpath(
string $path
)
:
void
Return real FS path of the file
Name | Type | Description |
---|---|---|
$path | string |
relativeName(
string $path
)
:
void
Return path of uploaded file relative to uploads dir
Name | Type | Description |
---|---|---|
$path | string |
set_for_soap(
string $filename, string $file
)
:
void
Setup for SOAP upload
Name | Type | Description |
---|---|---|
$filename | string | Name for the file |
$file | string |
tryRename(
string $filename, string $bean_id
)
:
void
Try renaming a file to bean_id name
Name | Type | Description |
---|---|---|
$filename | string | |
$bean_id | string |
unlink_file(
string $bean_id, string $file_name
=
''
)
:
void
deletes a file
Name | Type | Description |
---|---|---|
$bean_id | string | bean_id ID of the parent bean |
$file_name | string | file_name File's name |
upload_doc(
\SugarBean $bean, string $bean_id, string $doc_type, string $file_name, string $mime_type
)
:
void
Upload document to external service
Name | Type | Description |
---|---|---|
$bean | \SugarBean | Related bean |
$bean_id | string | |
$doc_type | string | |
$file_name | string | |
$mime_type | string |