Hi Dimmy + Subd
Can you give any more information about the file paths
I have downloaded the snippet and i’m calling it with my form template, i am receiving emails with an image attachment, but my modx database has no new tables ??
somehow this is working but i cant figure out where it is storing the files.
my snippet...
<?php
function eForm2db( &$fields )
{
/*---------------------------------------------------------------
eForm2db
Version: 0.1 [Beta 1]
Author: pixelchutes
---------------------------------------------------------------
Requirements:
eForm 1.4+
---------------------------------------------------------------
Use:
- Takes validated eForm submittal data for use with the MODx DBAPI extender class.
- Easily process database records referencing your form submission data:
+ INSERT new records to a table of your choice
+ UPDATE existing records if you'd prefer
+ DELETE records based on form submittal criteria
+ Form a query and return its record set as XML using $modx->db->getXML
+ Query a table's MetaData using $modx->db->getTableMetaData, followed by an update query
on only the form fields that are named after table columns!
+ and much more!
---------------------------------------------------------------*/
// Bring needed resources into scope
global $modx, $table_prefix, $_FILES;
if($fields['naam']&&$_FILES['image_name']){
// move number for to yes or no for sms
if($ifields['sms'] == 1){$ifields['sms'] = "ja";}else{$ifields['sms'] = "nee";}
//maak filename voor kleine foto
$filename= "/home/glamprod/public_html/assets/fotowedstijd/".$fields['naam'].".jpg";
$filepath = "/home/glamprod/public_html/assets/uploads/".$fields['naam'].".jpg";
// als file al bestaat plaats er een timestamp achter
$tijd = time();
if (file_exists($filename)) {
$filename = "/home/glamprod/public_html/assets/fotowedstijd/".$fields['naam'].$tijd.".jpg";
$filepath = "/home/glamprod/public_html/assets/uploads/".$fields['naam'].$tijd.".jpg";
}
// pak orgineel bestand en geef deze een naam
$filename_groot = "/home/glamprod/public_html/assets/fotowedstijd/".$fields['naam']."_groot.jpg";
$filepath_groot = "/home/glamprod/public_html/assets/uploads/".$fields['naam']."_groot.jpg";
// als file al bestaat plaats er een timestamp achter
if (file_exists($filename_groot)) {
$filename_groot = "/home/glamprod/public_html/assets/fotowedstijd/".$fields['naam'].$tijd."_groot.jpg";
$filepath_groot = "/home/glamprod/public_html/assets/uploads/".$fields['naam'].$tijd."_groot.jpg";
}
// geef de paden van de geuploade bestanden terug aan eform zodat deze in de database gescherven kunnen worden
// begin image manupulation
include('assets/snippets/fotowedstrijd/snapshot.class.php');
$myimage = new ImageSnapshot;
$myimage->Width = 165;
$myimage->Height = 190;
$myimage->Resize = true;
$myimage->ResizeScale = 100;
$myimage->Position = 'center';
$myimage->Compression = 80;
$myimage->ImageField = $_FILES['image_name'];
// geef de file aan de image processor voor schalen
$myimage->SaveImageAs($filename);
//sla orgineel bestand op
copy($_FILES['image_name']['tmp_name'], $filename_groot);
// pas de rechten aan zodat de bestanden gedouwnload kunnen worden.
chmod ($filename, 0755);
chmod ($filename_groot, 0755);
// end image manipulation
$fields['image'] = $filepath;
$fields['foto_groot'] = $filepath_groot;
//unset($fields['image']);
// Init our array
$dbTable = array(); // key = DB Column; Value = Insert/Update value
// Grab our table's columns
$tblColumns = array_keys( $modx->db->getTableMetaData( 'modx_fotowedstrijd' ) );
// Loop through each column, and insert it if present in the form
foreach( $tblColumns as $tblCol )
if( isset( $fields[ $tblCol ] ) ) $dbTable[ $tblCol ] = $fields[ $tblCol ];
// Insert field/value pairs to insert/update in our table
$dbTable[image] = $filepath;
$dbTable[foto_groot] = $filepath_groot ;
// INSERT - $dbQuery = $modx->db->insert( $dbTable, $table_prefix . 'insertTableName' );
// UPDATE - $dbQuery = $modx->db->update( $dbTable, $table_prefix . 'updateTableName' );
// DELETE - $dbQuery = $modx->db->delete( $table_prefix . 'deleteFromTableName', 'some_field = 1 AND name=\''.$dbTable[name].'\'', '' );
// etc...
// Run the db insert query
$dbQuery = $modx->db->insert( $dbTable, 'modx_fotowedstrijd' );
return true;
}
}
// Return empty string
return '';
?>
my form template...
[+validationmessage+]
<form action="[~[*id*]~]" id="EmailForm" method="post" name="EmailForm" enctype="multipart/form-data">
<fieldset>
<h3>Male Models</h3>
<input name="formid" type="hidden" value="ContactForm" />
<label for="cfName">Your name:
</label>
<p>
<input class="text" id="cfName" name="name" type="text" />
</p>
<label for="cfPhone">Contact number:
</label>
<p>
<input class="text" id="cfPhone" name="phone" type="text" />
</p>
<label for="cfEmail">Your Email Address:
</label>
<p>
<input class="text" id="cfEmail" name="email" type="text" />
</p>
<label for="cfDob">Your Date of Birth:
</label>
<p>
<input class="text" id="cfDob" name="dob" type="text" />
</p>
<label for="cfheight">Height:
</label>
<p>
<input class="text" id="cfheight" name="height" type="text" />
</p>
<label for="cfwaist">Waist:
</label>
<p>
<input class="text" id="cfwaist" name="waist" type="text" />
</p>
<label for="cfsuit">Suit Size:
</label>
<p>
<input class="text" id="cfsuit" name="suit" type="text" />
</p>
<p><label accesskey="i" for="image_name">Image</label>
<input name="image_name" type="file" />
</p>
<p>
Please tell us a little bit about yourself and if you have any modelling or dancing experience .
</p>
<label for="cfMessage">Message:
</label>
<p>
<textarea cols="50" id="cfMessage" name="message" rows="15"></textarea>
</p>
<p>
Please enter the verification code below: (to prevent spam)<br />
<br />
<img src="[+verimageurl+]" />
<input name="vericode" size="20" type="text" />
</p>
<label> </label>
<p>
<input class="button" id="cfContact" name="contact" type="submit" value="Send This Message" />
</p>
</fieldset>
</form>
and my snippet call...
[!eForm2db!]
[!eForm? &eFormOnBeforeMailSent=`eform2db` &formid=`ContactForm` &subject=`[+subject+] [+naam+]` &to=`[email protected]` &tpl=`MaleForm` &report=`upload_report` &vericode=`1` &gotoid=`74` !]
Any help would be much appreciated