- Getting Started
- Browser Support
- Languages Support
- Shortcuts
- Activation
- Examples
- Customize the Editor
- Use-cases
- Plugins
- APIs
- Development Frameworks
- Server Integrations
- Server SDKs
- Migration Guides
- Changelog
- Tutorials
PHP SDK File Reference
upload ($fileRoute, $options)
Returns: Object
Method used to upload file to the specified location on disk.
Parameters:
-
$fileRoute
The path relative to the
$_SERVER['DOCUMENT_ROOT']
global variable were the file should be uploaded.Type: String
-
$options
This parameter is optional. It can be used to pass custom options for the file upload.
Type: Array
$options parameter:
-
fieldname
The field name from the
$_FILES
global variable.Type: String Default: "file"
-
validation
An array or a function used to validate the uploaded file.
Type: Array or Function Default: array( 'allowedExts' => array('txt', 'pdf', 'doc'), 'allowedMimeTypes' => array('text/plain', 'application/msword', 'application/x-pdf', 'application/pdf') )
Response
If the upload is completed successfully, the method returns an object with the absolute path to the uploaded file. If an error occurs, the method returns an error.
try {
$response = FroalaEditor_File::upload('/uploads/');
echo stripslashes(json_encode($response));
}
catch (Exception $e) {
http_response_code(404);
}
delete ($src)
Returns: Boolean
Method used to delete a file from disk.
Parameters:
-
$src
The path relative to the
$_SERVER['DOCUMENT_ROOT']
global variable to the file that should be deleted.Type: String
Additional Resources
- Building a Support System Using Laravel PHP Framework and Froala HTML Editor Software – Part 1
- Building a Support System Using Laravel PHP Framework and Froala HTML Editor Software – Part 2
- Building a Support System Using Laravel PHP Framework and Froala HTML Editor Software – Part 3
- How To Use WYSIWYG Editor In PHP
Do you think we can improve this article? Let us know.