Zum Inhalt springen

Bild hochladen

Erstellt am 4. Januar 2012 · 4 Antworten · letzte Antwort am 6. Januar 2012

Tags: Frage

JakobRa ·

Hey,
erstmal euch allen ein gesundes neues Jahr!

Ich wollte gerade mal den Upload wie er >>hier<< beschrieben ist ausprobieren.

Habe mir also zuerst mal ein Objekt "Bild" erstellt mit dem DB-Feld "image text NOT NULL".

Im Model sieht das ganze so aus:

<?php
	/**
	 * bild
	 *
	 * @var string
	 */
	protected $bild;

	/**
	 * Returns the bild
	 *
	 * @return string $bild
	 */
	public function getBild() {
		return $this->bild;
	}

	/**
	 * Sets the bild
	 *
	 * @param string $bild
	 * @return void
	 */
	public function setBild($bild) {
		$this->bild= $bild;
	}
?>

...dazu habe ich mir diese Formular angelegt:

<f:form method="post" enctype="multipart/form-data" action="upload" controller="BildUpload" name="bild" object="{bild}">
<f:form.upload property="bild" />
<f:form.submit value="upload" />
</f:form>

...und natürlich die uploadAction:

<?php
/**
* Upload
* 
* @param Tx_MyUpload_Domain_Model_Bild $bild
* @return void
*/
public function uploadAction(Tx_MyUpload_Domain_Model_Bild $bild) {	
	toLog("Upload..." );
	$this->view->assign();
?>

Wenn ich nun versuch ein Bild hochzuladen, bekomme ich folgenden Fehler.

#1217839467: Could not ultimately dispatch the request after 101 iterations. Most probably, a @dontvalidate annotation is missing on re-displaying a form with validation errors.

Habe im Formular mal das "f:form.upload" durch ein "f:form.textbox" ersetzt, dann schreibt er mir zumindestens mein Log - das macht er beim ".upload" nicht.

Viele Grüße
Jakob

JakobRa ·

Kennt vielleicht jemand eine extbase Extension in der ich mir so einen Upload (File, Image usw.) mal anschauen kann?

Grüße
Jakob

JakobRa ·

Hallo Sven,
danke für den Tipp!

Habe mal das "nesting" hochgesetzt und "@dontvalidate" in die uploadAction geschrieben.
Leider beides ohne Erfolg.

Weiß jemand welchen Datentyp ich für ein Bild im Model brauche, kein "string"?

Übers BE kann ich ein "Bild" Objekt ohne Probleme anlegen.

Viele Grüße
Jakob

kainobi ·

Das @dontvalidate gehört imo nicht in die uploadAction (weil dort sollte ja nach dem Submit validiert werden), sondern in die newAction (oder wie auch immer die bei Dir heisst)...