加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 无法在drupal 7中添加图像字段

发布时间:2020-12-13 16:14:49 所属栏目:PHP教程 来源:网络整理
导读:我是drupal的新手,现在我需要以编程方式创建节点. 我能够创建一个简单的节点.但如果我将它与图像字段合并,它总是失败. $file_path = drupal_realpath('tmp/test_image.jpg');$file = (object) array( 'uid' = 1,'uri' = $file_path,'filemime' = file_get_mi
我是drupal的新手,现在我需要以编程方式创建节点.

我能够创建一个简单的节点.但如果我将它与图像字段合并,它总是失败.

$file_path = drupal_realpath('tmp/test_image.jpg');
$file = (object) array(
    'uid' => 1,'uri' => $file_path,'filemime' => file_get_mimetype($file_path),'status' => 1,);
$copy = file_copy($file,'public://sites/default/files/field/image/testing/',FILE_EXISTS_RENAME);
$node->field_image[LANGUAGE_NONE][0] = (array) $copy;

它总是给我一个错误:(

The specified file could not be copied,because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.

解决方法

我有同样的问题. 在我的情况下,问题是媒体配置“公共文件系统路径”被设置为相对路径站点/默认/文件.之后我设置了从根开始的绝对路径

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读