Examples demonstrating the Drupal File API (and Stream Wrappers).
The File Example module is a part of the Examples for Developers Project and provides various Drupal File API Examples. You can download and experiment with this code at the Examples for Developers project page.
See Drupal File API for handbook documentation on the File API and File summary on api.drupal.org for the function summary.
Functions
|
Name |
Location | Description |
|---|---|---|
| file_example_check_directory_submit |
file_example/ |
Submit handler to test directory existence. This actually just checks to see if the directory is writable |
| file_example_create_directory_submit |
file_example/ |
Submit handler for directory creation. Here we create a directory and set proper permissions on it using file_prepare_directory(). |
| file_example_delete_directory_submit |
file_example/ |
Submit handler for directory deletion. |
| file_example_delete_submit |
file_example/ |
Submit handler to delete a file. |
| file_example_file_check_exists_submit |
file_example/ |
Submit handler to check existence of a file. |
| file_example_get_managed_file |
file_example/ |
Utility function to check for and return a managed file. In this demonstration code we don't necessarily know if a file is managed or not, so often need to check to do the correct behavior. Normal code would not have to do this, as it would be… |
| file_example_intro |
file_example/ |
A simple introduction to the workings of this module. |
| file_example_managed_write_submit |
file_example/ |
Submit handler to write a managed file. |
| file_example_menu |
file_example/ |
Implements hook_menu() to set up the URLs (menu entries) for the file examples. |
| file_example_permission |
file_example/ |
Implements hook_permission(). |
| file_example_readwrite |
file_example/ |
Form builder function for the file example readwrite and directory creation example. |
| file_example_read_submit |
file_example/ |
Submit handler for reading a stream wrapper. |
| file_example_session_contents |
file_example/ |
Show the contents of a session file. |
| file_example_show_session_contents_submit |
file_example/ |
Utility submit function to show the contents of $_SESSION. |
| file_example_stream_wrappers |
file_example/ |
Implements hook_stream_wrappers(). hook_stream_wrappers() is Drupal's way of exposing the class that PHP will use to provide a new stream wrapper class. In this case, we'll expose the 'session' scheme, so a file reference like… |
| file_example_unmanaged_php_submit |
file_example/ |
|
| file_example_unmanaged_write_submit |
file_example/ |
Classes
|
Name |
Location | Description |
|---|---|---|
| FileExampleSessionStreamWrapper |
file_example/ |
Example stream wrapper class to handle session:// streams. |
File
- file_example/
file_example.module, line 7 - Examples demonstrating the Drupal File API (and Stream Wrappers).