【问题标题】:What path should I provide for imagecreatefrompng in separate folders joomla?我应该在单独的文件夹 joomla 中为 imagecreatefrompng 提供什么路径?
【发布时间】:2014-06-07 10:52:52
【问题描述】:

我一直在尝试在 joomla 中使用 imagecreatefrompng 函数。 我在 components/mycomponent/views/imgview/tmpl/default.php 中使用该函数 我必须将图像 url 管理员/组件/mycomponent/images/img.png 传递给它。

我尝试了很多方法。但这些都不起作用。是否有任何特定方法可以将 url 传递给该函数。 IE。我应该把它作为

$img = imagecreatefrompng('administrator/components/mycomponent/images/img.png');

$img = imagecreatefrompng('http://localhost/joomla/administrator/components/mycomponent/images/img.png');

$img = imagecreatefrompng('/var/www/joomla/administrator/components/mycomponent/images/img.png');

任何帮助将不胜感激。

【问题讨论】:

  • 您肯定希望使用路径,而不是 URL。您能否具体说明您在尝试使用其中一种调用时收到的任何错误?
  • 添加路径 $config 属性而不是硬编码。
  • @mario:按照你说的尝试。
  • @Elin:我最终将不得不添加配置路径。但现在对其进行硬编码以检查它现在是否有效......

标签: php url joomla path imagecreatefrompng


【解决方案1】:

如果您查看一些默认模板文件,Joomla 通常希望您使用 JPATH_ROOT 全局变量来确保您始终从站点根目录工作,如下所示:

$path = JPATH_ROOT . '/administrator/components/mycomponent/images/img.png';  
$img = imagecreatefrompng($path);

编辑:忘记第一个斜线。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-19
    • 2013-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多