SwatObject
└─SwatUIObject
└─SwatWidget
└─SwatControl
└─SwatInputControl
└─SwatFileEntry
public class SwatFileEntry
extends SwatInputControl
| Field Summary | |
|---|---|
| array | Array of mime-types to accept as uploads. |
| string | Access key. |
| boolean | Display maximum file upload size. |
| boolean | Display acceptable mime-types as a note in this entry's parent. |
| integer | The size in characters of the XHTML form input, or null if no width is specified. |
| Fields inherited from Swat.SwatInputControl | |
|---|---|
| required | |
| Method Summary | |
|---|---|
| void | display() Displays this entry widget. |
| private void | generateUniqueFileName(mixed path, mixed count) |
| protected array | Gets the array of CSS classes that are applied to this file entry widget. |
| mixed | Gets the original file name of the uploaded file. |
| string | Gets the id attribute of the XHTML element displayed by this widget that should receive focus. |
| static integer | Returns the size (in bytes) of the upload size limit of the PHP configuration. |
| mixed | Gets the mime type of the uploaded file. |
| SwatMessage | getNote() Gets a note specifying the mime types this file entry accepts. |
| mixed | getSize() Gets the size of the uploaded file in bytes. |
| mixed | Gets the temporary name of the uploaded file. |
| string | getUniqueFileName(string path) Gets a unique file name for the uploaded file for the given path. |
| protected SwatMessage | getValidationMessage(string id) Gets a validation message for this file entry. |
| boolean | Is file uploaded. |
| private static void | parseFileUploadSize(mixed ini_value) |
| void | process() Processes this file entry widget. |
| boolean | saveFile(string dst_dir, string dst_filename) Saves the uploaded file to the server. |
| Methods inherited from Swat.SwatInputControl | |
|---|---|
| getForm, init | |
| Methods inherited from Swat.SwatControl | |
|---|---|
| addMessage, getNote, printWidgetTree | |
| Methods inherited from Swat.SwatWidget | |
|---|---|
| addCompositeWidget, addMessage, confirmCompositeWidgets, copy, createCompositeWidgets, display, displayHtmlHeadEntries, getCSSClassNames, getCompositeWidget, getCompositeWidgets, getFocusableHtmlId, getHtmlHeadEntrySet, getMessages, hasMessage, init, isDisplayed, isInitialized, isProcessed, isSensitive, printWidgetTree, process, replaceWithContainer | |
| Methods inherited from Swat.SwatUIObject | |
|---|---|
| addComment, addJavaScript, addStyleSheet, addTangoAttribution, copy, getCSSClassNames, getCSSClassString, getFirstAncestor, getHtmlHeadEntrySet, getInlineJavaScript, getUniqueId, isVisible | |
public array $accept_mime_types = null
Array of mime-types to accept as uploads
public string $access_key = null
Access key
Access key for this file entry control, for keyboard nagivation.
public boolean $display_maximum_upload_size = false
Display maximum file upload size
public boolean $display_mime_types = true
Display acceptable mime-types as a note in this entry's parent
public integer $size = 40
The size in characters of the XHTML form input, or null if no width is specified
public void display()
Displays this entry widget
Outputs an appropriate XHTML tag.
private void generateUniqueFileName(mixed path, mixed count)
protected array getCSSClassNames()
Gets the array of CSS classes that are applied to this file entry widget
public mixed getFileName()
Gets the original file name of the uploaded file
public string getFocusableHtmlId()
Gets the id attribute of the XHTML element displayed by this widget that should receive focus
public static integer getMaximumFileUploadSize()
Returns the size (in bytes) of the upload size limit of the PHP configuration
The maximum upload size is calculated based on the php ini values for
upload_max_filesize and post_max_size. Be
aware that web server and POST data settings can also affect the
maximum upload size limit.
public mixed getMimeType()
Gets the mime type of the uploaded file
public SwatMessage getNote()
Gets a note specifying the mime types this file entry accepts
The file types are only returned if
SwatFileEntry::$display_mimetypes is set to true and
SwatFileEntry::$accept_mime_types has entries.
public mixed getSize()
Gets the size of the uploaded file in bytes
public mixed getTempFileName()
Gets the temporary name of the uploaded file
public string getUniqueFileName(string path)
Gets a unique file name for the uploaded file for the given path.
If the original file name is already unqiue, it will be used, otherwise a number will be appended to the end of the file name to make it unique.
path - where the file is to be savedprotected SwatMessage getValidationMessage(string id)
Gets a validation message for this file entry
Can be used by sub-classes to change the validation messages.
id - the string identifier of the validation message.public boolean isUploaded()
Is file uploaded
private static void parseFileUploadSize(mixed ini_value)
public void process()
Processes this file entry widget
If any validation type errors occur, an error message is attached to this entry widget.
public boolean saveFile(string dst_dir, string dst_filename)
Saves the uploaded file to the server
dst_dir - the directory on the server to save the uploaded file in.dst_filename - an optional filename to save the file under. If no filename is specified, the file is saved with the original filename.
A file upload widget
Note: Mime-type detection is done with the
Fileinfoextension if avaiable. Mime-type detection falls back to the mime_content_type() function if Fileinfo is not available but Fileinfo is highly recommended.