I am trying to upload/add an asset to an entry via a form on the website. The entry saves fine when I don't include the asset field but as soon as I add the asset field and try to upload a file I get this odd SQL error.
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
housewares
.craft_relations
, CONSTRAINTcraft_relations_targetId_fk
FOREIGN KEY (targetId
) REFERENCEScraft_elements
(id
) ON DELETE CASCADE).
The SQL statement executed was: INSERT INTOcraft_relations
(fieldId
,sourceId
,sourceLocale
,targetId
,sortOrder
,dateCreated
,dateUpdated
,uid
) VALUES (:row0_col0, :row0_col1, NULL, :row0_col3, :row0_col4, :row0_col5, :row0_col6, :row0_col7). Bound with :row0_col0='4', :row0_col1='27', :row0_col3='Golfclubs.jpg', :row0_col4=1, :row0_col5='2014-09-03 23:36:06', :row0_col6='2014-09-03 23:36:06', :row0_col7='a1e565e1-f6d3-4f3b-8a6f-2c049d236b13'
The field works fine in the CP.
This is the field
<input class="form-control" type="file" id="image" name="fields[image][]" />
Any ideas?