Zum Inhalt springen

Mailformplus Upload Variablen weitergeben

Erstellt am 8. Februar 2008 · 19 Antworten · letzte Antwort am 22. Februar 2008

Tags: Datei-Upload, Frage

Unbekannter Benutzer ·
$picture10 = $this->cObj->cObjGetSingle($this->conf['temp'], $this->conf['temp.'])

Parameter 1 ist die Info, welches Objekt das ist (eventuell funktionierts auch mit dem String 'TEXT', hab ich noch nie probiert).
Parameter 2 sind dann die TS-Optionen zum Objekt.

Info über die Befehle gibts online in der Doku der TYPO3 API. Wenn man was sucht, ist es sicher Anlaufstelle Nummer 1.

lg, Reinhard

David107 ·

Ok danke schonmal,
habs getestet, aber ich bekomme immer nur eine Fehlermeldung:
"Call to a member function on a non-object in ... "
Muss ich erst irgendwo eine Instanz erstellen um darauf zugreifen zu können?
Die anderen Beispiele hier im Forum haben mir leider nicht weiterhelfen können...
Oder muss ich die cObjGetSingle()Funktion ausführen bevor ich meine saveUserFunc ausführe?

David107 ·

Hallo ich bins nochmal 🙂
Ich hab folgendes probiert:

function user_save(&$params, &$ref){
	$this->params = $params;
	t3lib_div::debug($this->params,'unser debug');  
		
	$this->cObj = t3lib_div::makeInstance('tslib_cObj');
	$picture10 = $this->cObj->cObjGetSingle($this->params['config']['picture10'], $this->params['config']['picture10.']);

...

Über debug sehe ich logischerweise folgende Werte

config
picture10 TEXT
picture10. data GPVar:photouploadFiledata10

Aber in $picture10 steht nix drin

Auf $this->conf kann ich nicht zugreifen, weil es nicht mitübergeben wird.

Unbekannter Benutzer ·

Ich schätze mal du übergibst die Parameter so:

temp.filename = TEXT
temp.filename.data = GPVar:photouploadFiledata10

plugin.tx_thmailformplus_pi1.saveUserFunc = fileadmin/scripts/class.user_savedb.php:user_savedb->user_save
plugin.tx_thmailformplus_pi1.saveUserFunc.picture10 < temp.filename

Dann greifst du in der UserFunc so darauf zu:

...
function user_save($content = "", $conf = array()){
$this->cObj = t3lib_div::makeInstance('tslib_cObj');
$picture10 = $this->cObj->cObjGetSingle($conf['picture10'], $conf['picture10.']);
...
David107 ·

Hallo Reinhard,
Das hat leider nicht geklappt, in $picture10 steht nachwievor nichts drin.
Und wenn ich beim debug nachschaue, steht picture10 nicht unter $conf[picture10], sondern unter $conf[saveUserFunc.][picture10]. Das hat aber auch nicht geklappt.

David107 ·

Hier der Code, alles weiter hast du per PM
Das ist mein zuletzt funktionierender Code, deinen Vorschlag hab ich dort noch nicht drin.

#############################################################################
#### File-Upload Konfiguration
#############################################################################
plugin.tx_thmailformplus_pi1.fieldConf {
  photouploadFiledata10.fileUpload = uploads/mrapics/
  photouploadFiledata11.fileUpload = uploads/mrapics/
  photouploadFiledata12.fileUpload = uploads/mrapics/
  photouploadFiledata13.fileUpload = uploads/mrapics/
  
  photouploadFiledata20.fileUpload = uploads/mrapics/
  photouploadFiledata21.fileUpload = uploads/mrapics/
  photouploadFiledata22.fileUpload = uploads/mrapics/
  photouploadFiledata23.fileUpload = uploads/mrapics/
  
  photouploadFiledata30.fileUpload = uploads/mrapics/
  photouploadFiledata31.fileUpload = uploads/mrapics/
  photouploadFiledata32.fileUpload = uploads/mrapics/
  photouploadFiledata33.fileUpload = uploads/mrapics/  
  
  photouploadFiledata40.fileUpload = uploads/mrapics/
  photouploadFiledata41.fileUpload = uploads/mrapics/
  photouploadFiledata42.fileUpload = uploads/mrapics/
  photouploadFiledata43.fileUpload = uploads/mrapics/
}


#############################################################################
#### Speichern der Daten in der DB:user_mra und user_mra_enquiry mittels Hook
#############################################################################
plugin.tx_thmailformplus_pi1.saveUserFunc = fileadmin/scripts/class.user_savedb.php:user_savedb->user_save

temp.filename = TEXT
temp.filename.data = GPVar:photouploadFiledata10

plugin.tx_thmailformplus_pi1.saveUserFunc.picture10 < temp.filename
<?
class user_savedb extends tslib_pibase{
	function user_save(&$params, &$ref){
		$this->params = $params;
		//t3lib_div::debug($this->params,'Debug params');
		$this->cObj = t3lib_div::makeInstance('tslib_cObj');
	   	$picture10 = $this->cObj->cObjGetSingle($this->params['config']['picture10'], $this->params['config']['picture10.']);
		
		// Die per Formular uebertragenen Daten werden in die DB user_mra eingetragen
		$insertArray = array(
			'title' => $params['data']['title'],
			'firstname' => $params['data']['firstName'],
			'lastname' => $params['data']['lastName'],
			'company' => $params['data']['company'],
			'address' => $params['data']['address'],
			'address2' => $params['data']['address2'],
			'city' => $params['data']['city'],
			'postcode' => $params['data']['zip'],
			'country' => $params['data']['country'],
			'phone' => $params['data']['phone'],
			'fax' => $params['data']['fax'],
			'email' => $params['data']['email'],
			'contacttitle' => $params['data']['contactTitle'],
			'contactfirstname' => $params['data']['contactFirstName'],
			'contactlastname' => $params['data']['contactLastName'],
			'contactcompany' => $params['data']['contactCompany'],
			'contactaddress' => $params['data']['contactAddress'],
			'contactaddress2' => $params['data']['contactAddress2'],
			'contactcity' => $params['data']['contactCity'],
			'contactpostcode' => $params['data']['contactZip'],
			'contactcountry' => $params['data']['contactCountry'],
			'contactphone' => $params['data']['contactPhone'],
			'contactfax' => $params['data']['contactFax'],
			'contactemail' => $params['data']['contactEmail'],
			'deliverytitle' => $params['data']['deliveryTitle'],
			'deliveryfirstname' => $params['data']['deliveryFirstName'],
			'deliverylastname' => $params['data']['deliveryLastName'],
			'deliverycompany' => $params['data']['deliveryCompany'],
			'deliveryaddress' => $params['data']['deliveryAddress'],
			'deliveryaddress2' => $params['data']['deliveryAddress2'],
			'deliverycity' => $params['data']['deliveryCity'],
			'deliverypostcode' => $params['data']['deliveryZip'],
			'deliverycountry' => $params['data']['deliveryCountry'],
			'deliveryphone' => $params['data']['deliveryPhone'],
			'deliveryfax' => $params['data']['deliveryFax'],
			'deliveryemail' => $params['data']['deliveryEmail']
		);
		$res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('user_mra', $insertArray);
		
		// jedes Enquiry wird in die DB user_mra_enquiry eingetragen, mit der pid des Eintrags in user_mra
		$lastID=$GLOBALS['TYPO3_DB']->sql_insert_id();
		for ($i= 1; $i<5; $i++){
			if($params['data']['problemDescription'.$i.'']!=""){
				$insertArray2 = array(
					'pid' => $lastID,
					'productgroup' => $params['data']['productGroup'.$i.''],
					'type' => $params['data']['productType'.$i.''],
					'number' => $params['data']['serialNumber'.$i.''],
					'description' => $params['data']['problemDescription'.$i.''],
					'continously' => ($params['data']['errorFrequencyContinuously'.$i.'']!=""),
					'temperature' => ($params['data']['errorFrequencyTemperature'.$i.'']!=""),
					'installation' => ($params['data']['errorFrequencyInstallation'.$i.'']!=""),
					'months_check' => ($params['data']['errorFrequencyMonthsCheck'.$i.'']!=""),
					'months' => $params['data']['errorFrequencyMonths'.$i.''],
					'minutes_check' => ($params['data']['errorFrequencyMinutesCheck'.$i.'']!=""),
					'minutes' => $params['data']['errorFrequencyMinutes'.$i.''],
					'sometimes' => ($params['data']['errorFrequencySometimes'.$i.'']!=""),
					'never_used' => ($params['data']['errorFrequencyUnused'.$i.'']!=""),
					'cost_estimate' => ($params['data']['costEstimate'.$i.'']!=""),
					'repair_cost' => ($params['data']['repairWithCosts'.$i.'']!=""),
					'calibration_contact' => ($params['data']['workingStandard'.$i.'']!=""),
					'calibration_attached' => ($params['data']['dkdCalibration'.$i.'']!=""),
					'comments' => $params['data']['additionalComments'.$i.''],
					'image1' => $picture10,
					'image2' => $params['config']['picture'.$i.'1'],
					'image3' => $params['config']['picture'.$i.'2'],
					'image4' => $params['config']['picture'.$i.'3'],
				);		
				$res2 = $GLOBALS['TYPO3_DB']->exec_INSERTquery('user_mra_enquiry', $insertArray2);
			}
		}
	}
}

?>
Unbekannter Benutzer ·

Ich hab hier einen Auszug aus dem Quelltext deiner Seite:

...
<ul class="photoupload-queue" id="photoupload-queue-number">
    <li>
      <input type="file" name="photouploadFiledata-number0" id="photouploadFiledata-number0" />

    </li>
  </ul>
  <div id="downloadButton">
    <input type="button" onclick="addDownload(-number)" value="Hinzuf&uuml;gen">
    <input type="button" onclick="removeDownload(-number)" value="L&ouml;schen">
  </div>
...

Das FileUploadfeld heißt offensichtlich "photouploadFiledata-number0" und nicht
"photouploadFiledata10", also schätze ich mal, dass auch kein Get/Post-Parameter "photouploadFiledata10" übertragen wird.

Kann es sein, dass du einen Fehler in deinem JavaScript hast? Es werden die Funktionen addDownload und removeDownload mit dem Parameter "-number" aufgerufen, der anscheinend aber als String angehängt wird und nicht als Zahlenwert. Es ist sicher hiflreich, wenn du mal den Debugmodus von Mailformplus aktivierst und nach Absenden des Formulars schaust, welche Get/Post-Werte übertragen werden.

plugin.tx_thmailformplus_pi1.debug = 1

Vielleicht passiert tatsächlich ein Fehler bei der Namensgebung für die UploadFelder und das Problem liegt nicht im TS oder PHP!

lg, reinhard

David107 ·

Der Wert number wird vom JavaScript in die jeweilige nummer umgesetzt, das klappt soweit auch, kann man mit dem Firebug sehen.
Auch wenn ich folgende TS-Anweisung ausführe klappt es:

plugin.tx_thmailformplus_pi1.saveDB = 1
plugin.tx_thmailformplus_pi1.saveDB{
   dbTable=user_mra_enquiry
   dbkey=uid
   mapping=photouploadFiledata10:image1,photouploadFiledata11:image1,photouploadFiledata12:image1,photouploadFiledata13:image1
}

Nur möchte ich es ja selbst abspeichern und nicht mittels saveDB