include/upload_file.php

Show: inherited
Table of Contents

\UploadFile

Package: SugarCRM

Api
Manage uploaded files  

Properties

Propertypublic  $field_name= ''
Details
Type
n/a
Propertypublic  $file= ''
Details
Type
n/a
Propertypublic  $file_ext= ''
Details
Type
n/a
Propertyprotectedarray  $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.', )'
static

Upload errors

Default valuearray( 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
Propertypublic  $original_file_name= ''
Details
Type
n/a
Propertypublic  $stored_file_name= ''
Details
Type
n/a
Propertypublic  $temp_file_location= ''
Details
Type
n/a
Propertyprotected  $url= '"upload/"'
static
Default value"upload/"Details
Type
n/a
Propertypublic  $use_soap= 'false'
Default valuefalseDetails
Type
n/a

Methods

methodpublicUploadFile( string $field_name = '' ) : void

Create upload file handler

Parameters
Name Type Description
$field_name string

Form field name

methodpublicconfirm_upload( ) : bool

standard PHP file-upload security measures. all variables accessed in a global context

Returns
Type Description
bool True on success
methodpubliccreate_stored_filename( ) : string

creates a file's name for preparation for saving

Returns
Type Description
string
methodpublicduplicate_file( string $old_id, string $new_id, string $file_name ) : void
static

duplicates an already uploaded file in the filesystem.

Parameters
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)

methodpublicfinal_move( string $bean_id ) : bool

moves uploaded temp file to permanent save location

Parameters
Name Type Description
$bean_id string

bean_id ID of parent bean

Returns
Type Description
bool True on success
methodpublicgetMime( array $_FILES_element ) : string

Get MIME type for uploaded file

Parameters
Name Type Description
$_FILES_element array

$_FILES element required

Returns
Type Description
string MIME type
methodpublicgetMimeSoap( string $filename ) : string

Guess MIME type for file

Parameters
Name Type Description
$filename string
Returns
Type Description
string MIME type
methodpublicget_file_path( string $stored_file_name, string $bean_id,  $skip_rename = false ) : string
static

builds a URL path for an anchor tag

Parameters
Name Type Description
$stored_file_name string

stored_file_name File name in filesystem

$bean_id string

bean_id note bean ID

$skip_rename
Returns
Type Description
string path with file name
methodpublicget_stored_file_name( ) : string

gets note's filename

Returns
Type Description
string
methodpublicget_upload_dir( ) : string

Get upload file location prefix

Returns
Type Description
string prefix
methodpublicget_upload_error( ) : string

Get upload error from system

Returns
Type Description
string upload error
methodpublicget_upload_path( string $bean_id ) : string

returns the path with file name to save an uploaded file

Parameters
Name Type Description
$bean_id string

bean_id ID of the parent bean

Returns
Type Description
string
methodpublicget_upload_url( \SugarBean $document, string $type = null ) : void
static

Get URL of the uploaded file related to the document

Parameters
Name Type Description
$document \SugarBean
$type string

Type of the document, if different from $document

methodpublicget_url( string $stored_file_name, string $bean_id ) : string
static

Get URL for a document

Parameters
Name Type Description
$stored_file_name string

stored_file_name File name in filesystem

$bean_id string

bean_id note bean ID

Returns
Type Description
string path with file name
Details
Deprecated
 
methodpublicrealpath( string $path ) : void
static

Return real FS path of the file

Parameters
Name Type Description
$path string
methodpublicrelativeName( string $path ) : void
static

Return path of uploaded file relative to uploads dir

Parameters
Name Type Description
$path string
methodpublicset_for_soap( string $filename, string $file ) : void

Setup for SOAP upload

Parameters
Name Type Description
$filename string

Name for the file

$file string
methodprotectedtryRename( string $filename, string $bean_id ) : void
static

Try renaming a file to bean_id name

Parameters
Name Type Description
$filename string
$bean_id string
methodpublicunlink_file( string $bean_id, string $file_name = '' ) : void
static

deletes a file

Parameters
Name Type Description
$bean_id string

bean_id ID of the parent bean

$file_name string

file_name File's name

methodpublicupload_doc( \SugarBean $bean, string $bean_id, string $doc_type, string $file_name, string $mime_type ) : void

Upload document to external service

Parameters
Name Type Description
$bean \SugarBean

Related bean

$bean_id string
$doc_type string
$file_name string
$mime_type string
Documentation was generated by DocBlox 0.18.1.