<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 "<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>", or a relative URL (relative to the Drupal document root) "/sites/all/themes/my_theme/images/cool_logo.png".<br>
<br>This is complicated by the fact that for CSS, a background image would be:<br><br>#mission {<br> background transparent url(images/background.png);<br>}<br><br>Now, let'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 -> filepath property. The absolute path can be attained like this:<br><br> $filedir = realpath('.') . '/' . $file -> filepath;<br>
$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 "opendir(files/path_to_image)", 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(".")) 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"><<a href="mailto:john@rivul.com">john@rivul.com</a>></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("files/"); <br>
but this doesn't: </font></font><font size="-1"><font face="Helvetica, Arial, sans-serif">opendir(base_path() ."files/"); <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 <?php base_path() .
'files' ?> 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"><<a href="mailto:john@rivul.com" target="_blank">john@rivul.com</a>></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()? It returns "files", 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't get
anything other than "/" returned by base_path(), regardless of the
level I'm on. 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 <?php base_path() .
'files' ?><br>
<br>
<div class="gmail_quote">On Sat, Aug 2, 2008 at 9:15 AM, John
Horning <span dir="ltr"><<a href="mailto:john@rivul.com" target="_blank">john@rivul.com</a>></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.
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>
<?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);">?></span></span>/box_bottom.png<br>
<br>
</code><code><img src="<span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 187);"><?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);">"/pic/mary.png"</span><span style="color: rgb(0, 119, 0);">; </span><span style="color: rgb(0, 0, 187);">?></span></span>" /></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"><<a href="mailto:john@rivul.com" target="_blank">john@rivul.com</a>></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. I have a script in my
page.tpl.php that randomly picks images from a directory and displays
them in the header. This works when you're on the top level, but not
below since I'm using a relative path to get to the image directory.
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>