Class fileupload
fileupload
Classes extended from fileupload: ^TOP
Located in File: <ROOT>/class/fileupload.php
On submit page:
include_once('fileupload.php');
$upload = new fileupload();
$upload->set_max_file_size(50, 'k', 'myfile');
$upload->render(1, 'myfield');
--------------------
On upload page:
include_once('fileupload.php');
$upload = new fileupload();
$upload->set_upload_dir('/myfolder', 'myfile');
$result = $upload->upload();
if ($result) {
print_r($result['myfile']);
}
$upload->errors(1);
-----------------------
Of course there are many other options. This is just a very basic sample.
Note:
Filenames/Extensions are always converted to lowercase and may only contain the following NON
accentuated characters (A-Z a-z 0-9 _ . -) Anything else (including spaces) will be stripped!
Method Summary
^TOP
|
string errors ( [$style = 0], [$html = 1] )
Returns all errors if any
|
type render ( [$style = 0], [$field = ''] )
Description
|
void set_accepted ( [$value = '.*'], [$filename = 'uploaded_files'] )
Sets allowable file extensions
|
void set_basename ( $value, [$filename = 'uploaded_files'] )
Cleans up & sets the base filename without the extension
|
void set_chmod ( [$value = 0666], [$filename = 'uploaded_files'] )
Sets the chmod value, if any that should be applied to uploaded files
|
void set_extension ( $value, [$filename = 'uploaded_files'] )
Sets if a extension should be forced on the file
|
void set_filecleanup ( [$value = 0], [$filename = 'uploaded_files'] )
Sets if the uploaded file should be cleaned up or not (only applies to text type files)
|
void set_max_file_size ( [$size = 0], [$type = 'b'], [$filename = 'uploaded_files'] )
Set the maximum file size in bytes ($size), allowable by the object.
|
void set_max_image_height ( [$height = 0], [$filename = 'uploaded_files'] )
Sets the maximum pixel height for image uploads, O means unlimited
|
void set_max_image_width ( [$width = 0], [$filename = 'uploaded_files'] )
Sets the maximum pixel width for image uploads, O means unlimited
|
type set_overwrite ( [$value = 0], [$filename = 'uploaded_files'] )
Description
|
void set_upload_dir ( $upload_dir, [$filename = 'uploaded_files'] )
Sets the path to which the files should be uploaded to
|
array upload ( )
The upload function called to start processing the whole upload process
|
$accepted
Data type: mixed
$def_accepted
Data type: mixed
$def_chmod
Data type: mixed
$def_max_file_size
Data type: mixed
$def_max_image_height
Data type: mixed
$def_max_image_width
Data type: mixed
$def_overwrite
Data type: mixed
$errors
Data type: mixed
$file
Data type: mixed
$max_file_size
Data type: mixed
errors
Useage :
string
errors ( [$style = 0], [$html = 1] )
Description :
Returns all errors if any
- Function Parameters:
- - bool $html If TRUE, then errors are in html format, otherwise in plaintext
- Function Info:
- Return - HTML/TEXT formated errors if any
render
Useage :
type
render ( [$style = 0], [$field = ''] )
Description :
Description
- Function Parameters:
- - type $var description
- Function Info:
- Return - description
set_accepted
Useage :
void
set_accepted ( [$value = '.*'], [$filename = 'uploaded_files'] )
Description :
Sets allowable file extensions
- Function Parameters:
- - string $value A list of accepted extensions delimited by | (ie .gif|.png)
- Function Info:
set_basename
Useage :
void
set_basename ( $value, [$filename = 'uploaded_files'] )
Description :
Cleans up & sets the base filename without the extension
Don't call this if uploading multiple files ..use $this->add_field() instead!
Only applies to 1st file if uploading multiple files
- Function Parameters:
- - string $value The base filename without any extension.
- Function Info:
set_chmod
Useage :
void
set_chmod ( [$value = 0666], [$filename = 'uploaded_files'] )
Description :
Sets the chmod value, if any that should be applied to uploaded files
- Function Parameters:
- - int $value Numric value to chmod the file to
- Function Info:
set_extension
Useage :
void
set_extension ( $value, [$filename = 'uploaded_files'] )
Description :
Sets if a extension should be forced on the file
Only use this if you realy need to force a extension!
Only applies to 1st file if uploading multiple files
- Function Parameters:
- - string $value File extension including .
- Function Info:
set_filecleanup
Useage :
void
set_filecleanup ( [$value = 0], [$filename = 'uploaded_files'] )
Description :
Sets if the uploaded file should be cleaned up or not (only applies to text type files)
- Function Parameters:
- - bool $cleanup Wether to clean files or not
- Function Info:
set_max_file_size
Useage :
void
set_max_file_size ( [$size = 0], [$type = 'b'], [$filename = 'uploaded_files'] )
Description :
Set the maximum file size in bytes ($size), allowable by the object.
- Function Parameters:
- - int $size Maximum file size.
- - string $type What $size refers to -> m: MegaBytes, k: KiloBytes, b: Bytes
- Function Info:
set_max_image_height
Useage :
void
set_max_image_height ( [$height = 0], [$filename = 'uploaded_files'] )
Description :
Sets the maximum pixel height for image uploads, O means unlimited
- Function Parameters:
- - int $height Maximum pixel height of image uploads
- Function Info:
set_max_image_width
Useage :
void
set_max_image_width ( [$width = 0], [$filename = 'uploaded_files'] )
Description :
Sets the maximum pixel width for image uploads, O means unlimited
- Function Parameters:
- - int $width Maximum pixel width of image uploads
- Function Info:
set_overwrite
Useage :
type
set_overwrite ( [$value = 0], [$filename = 'uploaded_files'] )
Description :
Description
- Function Parameters:
- - int $value Set the file overwrite mode
0: Do nothing if exists
1: Make copy
2: Overwrite file
- Function Info:
- Return - description
set_upload_dir
Useage :
void
set_upload_dir ( $upload_dir, [$filename = 'uploaded_files'] )
Description :
Sets the path to which the files should be uploaded to
- Function Parameters:
- - string $upload_dir Path to upload files to
- Function Info:
upload
Useage :
array
upload ( )
Description :
The upload function called to start processing the whole upload process
- Function Parameters:
- Function Info:
- Return - An array of all succesfully uploaded files if any, with various information on each file