Hallo JoomlaHatesMe,
danke für deine Antwort. Ich habe es probiert und jetzt geht gleich alles schief. Hier ist meine Anweisung:
Code:
if( $imagename != null )
{
$project_folder = "images".DS."mysite".DS."projects".DS.JString::strtolower( JString::str_ireplace( ' ', '_', $row->titel ) );
* check if project folder (the image target) already exists in root/images/mysite */
if( !JFolder::exists( $project_folder ) )
{
/* if not, create and name it the project name */
JFolder::create( $project_folder );
}
$img_src_path = $image['tmp_name'];
/* IMPORTANT: the path must end with the filename - otherwise copying will fail !!! */
$img_dest_path = $project_folder.DS.$imagename;
/* copy the image to the project folder */
if( !JFile::upload( $img_src_path, $img_dest_path ) )
{
JError::raiseWarning( 100, 'ERROR: Image not uploaded ' . $row->getError() );
return false;
}
/* set the image name for storing in database */
$row->thumbnail = $imagename;
$row->thumbnail_path = JString::str_ireplace( "\\", "/", $project_folder . DS );
}
Damit passiert folgendes:
1. In die Datenbank wird als Pfad geschrieben
images/mysite/projects/test_test2/
So ist es gewünscht und das Bild wird in meiner Komponente im Backend auch angezeigt. ABER: Der verwendete Pfad ist laut HTML Quelltext auf einmal
Code:
http://localhost/joomla/administrator/images/mysite/projects/test_test2/thumb.jpg
Wie kann das denn sein? Entsprechend wird der Ordner "images" auch im Verzeichnis "administrator" angelegt und nicht da, wo der Datenbankpfad hinweist. Das entspricht doch aber garnicht meiner Anweisung!?
2. Im Frontend weise ich an
Code:
<img src="<?php echo $this->project->thumbnail_path . $this->project->thumbnail; ?>"
alt="" width="80" height="80"
title="Thumbnail of project <?php echo $this->project->titel; ?>" />
Das Bild wird NICHT angezeigt. Als Pfad wird hier im HTML Quelltext angezeigt:
Code:
http://localhost/joomla/images/mysite/projects/test_test2/thumb.jpg
Das ist der Pfad, der angewiesen wurde.
3. mit der Anweisung
Code:
$project_folder = JURI::base( "images".DS."mysite".DS."projects".DS.JString::strtolower( JString::str_ireplace( ' ', '_', $row->titel ) ) );
bekomme ich in die Datenbank als Thumbnail Pfad ganz und gar Blödsinn, nämlich
Code:
/joomla/administrator/
Was läuft denn nun wieder schief?
Lesezeichen