ya.*_*eck 5 php drupal filestream drupal-7
我需要从下载的文件中读取一些元信息.但我不知道该怎么做.
这是我的代码:
// Path form field_file
$file = 'public://directory/filename.txt';
file_get_contents($file);
Run Code Online (Sandbox Code Playgroud)
此代码导致此警告:
警告:file_get_contents():无法找到包装器"public" - 您是否忘记在配置PHP时启用它?
知道我做错了什么吗?
有三个内部流包装器private、public和tempor ,它们在此文件中定义。
您可能需要file_get_mimetype(), file_get_contents 是一个 PHP 函数,并且不知道 drupal 文件 api。
file_get_contents(drupal_realpath($file));
Run Code Online (Sandbox Code Playgroud)
会起到阅读的作用。
对于上传,请查看file_save_upload()