<div dir="ltr">ok, John, you have to understand the difference between URLs, on the one hand, and file system paths, on the other.<br><br>When you are generating a path for an image, say a logo, in order to specify a SRC attribute, that path must be a URL for apache to use and not a file system path. In other words, either &quot;<a href="http://example.com/sites/all/themes/my_theme/images/cool_logo.png">http://example.com/sites/all/themes/my_theme/images/cool_logo.png</a>&quot;, or a relative URL (relative to the Drupal document root) &quot;/sites/all/themes/my_theme/images/cool_logo.png&quot;.<br>
<br>This is complicated by the fact that for CSS, a background image would be:<br><br>#mission {<br>&nbsp; background transparent url(images/background.png);<br>}<br><br>Now, let&#39;s say you need to get the file system path to an image in order to open it up and get its properties, however, like width and height, because you want to make a thumbnail on the fly.<br>
<br>The following works for me. Assuming I open up an image node and can access its $file -&gt; filepath property. The absolute path can be attained like this:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $filedir = realpath(&#39;.&#39;) . &#39;/&#39; . $file -&gt; filepath;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $info = image_get_info($filedir);<br><br>That works for me, perhaps someone has a better way of doing this.<br><br>The relative file system path woujld be your &quot;opendir(files/path_to_image)&quot;, which works in many cases (all?). The reason it works is because the current directory is the Drupal document root (is where PHP is executing normally), so my absolute path above depends on this (realpath(&quot;.&quot;)) as does your relative path.<br>
<br>Perhaps the best lesson is, if it works for you, use it. But you must understand the difference between URLs and functions which return URLs, and file system paths, and functions which return these.<br><br>Victor Kane<br>
<a href="http://awebfactory.com.ar">http://awebfactory.com.ar</a><br><br><br><br><br><div class="gmail_quote">On Sat, Aug 2, 2008 at 11:20 PM, John Horning <span dir="ltr">&lt;<a href="mailto:john@rivul.com">john@rivul.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


  

<div bgcolor="#ffffff" text="#333333">
<font size="-1"><font face="Helvetica, Arial, sans-serif">For some
reason this works from deeper directory levels: opendir(&quot;files/&quot;);&nbsp; <br>
but this doesn&#39;t: </font></font><font size="-1"><font face="Helvetica, Arial, sans-serif">opendir(base_path() .&quot;files/&quot;);&nbsp; <br>
<br>
Is this a misapplication?<br>
</font></font><div><div></div><div class="Wj3C7c"><br>
<font size="-1"><font face="Helvetica, Arial, sans-serif"><br>
</font></font><br>
Victor Kane wrote:
<blockquote type="cite">
  <div dir="ltr">Well, assuming you are talking about URLs, you should
be all set. All Drupal modules see the world from the Drupal document
root, so &lt;?php base_path() .
&#39;files&#39; ?&gt; should be fine for a URL.<br>
  <br>
What is it you cannot get done?<br>
  <br>
  <div class="gmail_quote">On Sat, Aug 2, 2008 at 1:01 PM, John Horning
  <span dir="ltr">&lt;<a href="mailto:john@rivul.com" target="_blank">john@rivul.com</a>&gt;</span> wrote:<br>
  <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div bgcolor="#ffffff" text="#333333">
    <font size="-1"><font face="Helvetica, Arial, sans-serif">Do you
know
anything about file_directory_path()?&nbsp; It returns &quot;files&quot;, which is
correct for use from the home directory, but not useful on other levels.<br>
    <br>
    </font></font>
    <div>
    <div><br>
John Horning wrote:
    <blockquote type="cite"> <font size="-1"><font face="Helvetica, Arial, sans-serif">I can&#39;t get
anything other than &quot;/&quot; returned by base_path(), regardless of the
level I&#39;m on.&nbsp; I must be missing something.<br>
      <br>
      </font></font><br>
Victor Kane wrote:
      <blockquote type="cite">
        <div dir="ltr">As URL?<br>
        <br>
Assuming it were ./files, then try sthg like &lt;?php base_path() .
&#39;files&#39; ?&gt;<br>
        <br>
        <div class="gmail_quote">On Sat, Aug 2, 2008 at 9:15 AM, John
Horning <span dir="ltr">&lt;<a href="mailto:john@rivul.com" target="_blank">john@rivul.com</a>&gt;</span>
wrote:<br>
        <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
          <div bgcolor="#ffffff" text="#333333"> <font size="-1"><font face="Helvetica, Arial, sans-serif">Thanks.&nbsp;
Is
there something like that to get me to the files directory?<br>
John<br>
          </font></font><br>
Victor Kane wrote:
          <blockquote type="cite">
            <div>
            <div>
            <div dir="ltr"><code><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 187);">Try the following:<br>
            <br>
&lt;?php base_path</span><span style="color: rgb(0, 119, 0);">() . </span><span style="color: rgb(0, 0, 187);">path_to_theme</span><span style="color: rgb(0, 119, 0);">() </span><span style="color: rgb(0, 0, 187);">?&gt;</span></span>/box_bottom.png<br>

            <br>
            </code><code>&lt;img src=&quot;<span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 187);">&lt;?php </span><span style="color: rgb(0, 119, 0);">print </span><span style="color: rgb(0, 0, 187);">base_path</span><span style="color: rgb(0, 119, 0);">() . </span><span style="color: rgb(0, 0, 187);">path_to_theme</span><span style="color: rgb(0, 119, 0);">() . </span><span style="color: rgb(221, 0, 0);">&quot;/pic/mary.png&quot;</span><span style="color: rgb(0, 119, 0);">; </span><span style="color: rgb(0, 0, 187);">?&gt;</span></span>&quot; /&gt;</code><br>

            <br>
Victor Kane<br>
            <a href="http://awebfactory.com.ar" target="_blank">http://awebfactory.com.ar</a><br>
            <br>
            <div class="gmail_quote">On Fri, Aug 1, 2008 at 10:28 PM,
John
Horning <span dir="ltr">&lt;<a href="mailto:john@rivul.com" target="_blank">john@rivul.com</a>&gt;</span>
wrote:<br>
            <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
              <div bgcolor="#ffffff" text="#333333">Apparently Drupal
does
not allow you to reference absolute URL paths in
scripts, which is causing me a problem.&nbsp; I have a script in my
page.tpl.php that randomly picks images from a directory and displays
them in the header.&nbsp; This works when you&#39;re on the top level, but not
below since I&#39;m using a relative path to get to the image directory.&nbsp;
Can anyone tell me the proper way of doing this?<br>
              </div>
              <br>
--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a>
]<br>
            </blockquote>
            </div>
            <br>
            </div>
            </div>
            </div>
            <pre>No virus found in this incoming message.
Checked by AVG - <a href="http://www.avg.com" target="_blank">http://www.avg.com</a> 
Version: 8.0.138 / Virus Database: 270.5.10/1585 - Release Date: 8/1/2008 6:39 AM
  </pre>
          </blockquote>
          </div>
          <br>
--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a>
]<br>
        </blockquote>
        </div>
        <br>
        </div>
        <pre>No virus found in this incoming message.
Checked by AVG - <a href="http://www.avg.com" target="_blank">http://www.avg.com</a> 
Version: 8.0.138 / Virus Database: 270.5.10/1586 - Release Date: 8/1/2008 6:59 PM
  </pre>
      </blockquote>
      <pre>No virus found in this incoming message.
Checked by AVG - <a href="http://www.avg.com" target="_blank">http://www.avg.com</a> 
Version: 8.0.138 / Virus Database: 270.5.10/1586 - Release Date: 8/1/2008 6:59 PM
  </pre>
    </blockquote>
    </div>
    </div>
    </div>
    <br>
--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a>
]<br>
  </blockquote>
  </div>
  <br>
  </div>
  <pre>No virus found in this incoming message.
Checked by AVG - <a href="http://www.avg.com" target="_blank">http://www.avg.com</a> 
Version: 8.0.138 / Virus Database: 270.5.10/1586 - Release Date: 8/1/2008 6:59 PM
  </pre>
</blockquote>
</div></div></div>

<br>--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br></blockquote></div><br></div>