Closed Thread Icon

Topic awaiting preservation: DIRECTORY_SEPARATOR HELP! (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=31035" title="Pages that link to Topic awaiting preservation: DIRECTORY_SEPARATOR HELP! (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: DIRECTORY_SEPARATOR HELP! <span class="small">(Page 1 of 1)</span>\

 
Hustluz
Bipolar (III) Inmate

From:
Insane since: Jun 2003

posted posted 06-07-2009 03:03

My code is as follows
1. Define the directory separator as DS constant

code:
defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);



2. then i use this method on the photographs class

code:
public function image_path(){
		return 	$this->upload_dir.DS.$this->filename;
	}



i have a protected attribute for my photograph class this is called:

code:
protected $upload_dir = "images";



3. i loop through the pictures and attributes in this table

code:
<table class="bordered">
    	<tr>
        	<th>Image</th>
            <th>Filename</th>
            <th>Caption</th>
            <th>Size</th>
            <th>Type</th>
		</tr>
    <?php echo DS ?>
	<?php foreach($photos as $photo): ?>
    	<tr>
        	<td><img src="../<?php echo $photo->image_path(); ?>" width="100" /></td>
            <td><?php echo $photo->filename; ?></td>
            <td><?php echo $photo->caption; ?></td>
            <td><?php echo $photo->size; ?></td>
            <td><?php echo $photo->type; ?></td>
		</tr>
	<?php endforeach; ?>
    </table>



but the picture file link is broken and give me this in the source code for the picture location

code:
<img src="../images\oday.png" width="100" />



im guess that the DS is not giving me the right directory separator what am i doing wrong please help. Thank you in advanc

DL-44
Lunatic (VI) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 06-07-2009 06:31

perhaps relevant: http://old.alanhogan.com/tips/php/directory-separator-not-necessary

Hustluz
Bipolar (III) Inmate

From:
Insane since: Jun 2003

posted posted 06-07-2009 14:26

Thank you DL-44

sherman
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Jan 2010

posted posted 01-09-2010 04:03
quote:

Hustluz said:

Thank you DL-44



What did you do, mate? I'm struggling with the same code presented by Kevin you know. In my case photos simply did not appear in the table sells. No errors I've recieved. Wicked...

Hustluz
Bipolar (III) Inmate

From:
Insane since: Jun 2003

posted posted 01-15-2010 04:03

oh sorry i didnt put it.. i have a mac now so the code works just fine.. but i just defined the directory separator like this

code:
define('DS', "/")



i forget if it was the forward slash or backslash but one of them work.. i know its not the ideal way but it works just fine and gets the job done. and later if we do fine out what is wrong its a quick fix to just change it to whatever works for both cases.

« BackwardsOnwards »

Show Forum Drop Down Menu