I need to read some meta information from the downloaded file. But I do not know how to do it.
Here is my code:
// Path form field_file
$file = 'public://directory/filename.txt';
file_get_contents($file);
This code causes this warning:
Warning: file_get_contents(): Unable to find the wrapper "public" - did you forget to enable it when you configured PHP?
Any idea of what I am doing wrong, please?
There are three internal stream wrappers private, public and temporary, they are defined in this file.
You may want file_get_mimetype(), file_get_contents is a PHP function and won't be aware of the drupal file api.
file_get_contents(drupal_realpath($file));
Would do the trick for reading.
For an upload take a look at file_save_upload()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With