GithubHelp home page GithubHelp logo

Can't save images about guest-entries HOT 5 CLOSED

craftcms avatar craftcms commented on August 29, 2024
Can't save images

from guest-entries.

Comments (5)

edalzell avatar edalzell commented on August 29, 2024 1

I solved this @wallacio, I didn't have the enctype=multipart/form-data set on the form tag, that caused that integrity constraint

from guest-entries.

edalzell avatar edalzell commented on August 29, 2024

Current version of Guest Entries

from guest-entries.

edalzell avatar edalzell commented on August 29, 2024

now I'm getting a integrity constraint error:
image

What would cause that?

from guest-entries.

wallacio avatar wallacio commented on August 29, 2024

The very same for me, unfortunately.

Guest Entries: 2.3.0
Craft Pro 3.4.24

I have two fields which are of type Asset.
Form fields of the format:

<input type="file" name="fields[participantRouteImage][]" id="participantRouteImage" class="custom-file-input">
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`databasename`.`relations`, CONSTRAINT `relations_targetId_fk` FOREIGN KEY (`targetId`) REFERENCES `elements` (`id`) ON DELETE CASCADE)
The SQL being executed was: INSERT INTO `relations` (`fieldId`, `sourceId`, `sourceSiteId`, `targetId`, `sortOrder`, `dateCreated`, `dateUpdated`, `uid`) VALUES (617, 50112, NULL, 20190629, 1, '2020-06-18 15:30:38', '2020-06-18 15:30:38', '333792e8-7809-4a10-9bc4-49cc204914e2')

Stack trace:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`databasename`.`relations`, CONSTRAINT `relations_targetId_fk` FOREIGN KEY (`targetId`) REFERENCES `elements` (`id`) ON DELETE CASCADE) in .../application/vendor/yiisoft/yii2/db/Command.php:1293
Stack trace:
#0 .../application/vendor/yiisoft/yii2/db/Command.php(1293): PDOStatement->execute()
#1 .../application/vendor/yiisoft/yii2/db/Command.php(1093): yii\db\Command->internalExecute('INSERT INTO `re...')
#2 .../application/vendor/craftcms/cms/src/services/Relations.php(110): yii\db\Command->execute()
#3 .../application/vendor/craftcms/cms/src/fields/BaseRelationField.php(746): craft\services\Relations->saveRelations(Object(craft\fields\Assets), Object(craft\elements\Entry), Array)
#4 .../application/vendor/craftcms/cms/src/fields/Assets.php(546): craft\fields\BaseRelationField->afterElementSave(Object(craft\elements\Entry), true)
#5 .../application/vendor/craftcms/cms/src/base/Element.php(2559): craft\fields\Assets->afterElementSave(Object(craft\elements\Entry), true)
#6 .../application/vendor/craftcms/cms/src/elements/Entry.php(1301): craft\base\Element->afterSave(true)
#7 .../application/vendor/craftcms/cms/src/services/Elements.php(2166): craft\elements\Entry->afterSave(true)
#8 .../application/vendor/craftcms/cms/src/services/Elements.php(531): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, false, true)
#9 .../application/vendor/craftcms/guest-entries/src/controllers/SaveController.php(137): craft\services\Elements->saveElement(Object(craft\elements\Entry))
#10 [internal function]: craft\guestentries\controllers\SaveController->actionIndex()
#11 .../application/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 .../application/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#13 .../application/vendor/craftcms/cms/src/web/Controller.php(178): yii\base\Controller->runAction('', Array)
#14 .../application/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('', Array)
#15 .../application/vendor/craftcms/cms/src/web/Application.php(291): yii\base\Module->runAction('guest-entries/s...', Array)
#16 .../application/vendor/craftcms/cms/src/web/Application.php(559): craft\web\Application->runAction('guest-entries/s...', Array)
#17 .../application/vendor/craftcms/cms/src/web/Application.php(270): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#18 .../application/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#19 .../application/web/index.php(21): yii\base\Application->run()
#20 {main}

Next yii\db\IntegrityException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`databasename`.`relations`, CONSTRAINT `relations_targetId_fk` FOREIGN KEY (`targetId`) REFERENCES `elements` (`id`) ON DELETE CASCADE)
The SQL being executed was: INSERT INTO `relations` (`fieldId`, `sourceId`, `sourceSiteId`, `targetId`, `sortOrder`, `dateCreated`, `dateUpdated`, `uid`) VALUES (617, 50112, NULL, 20190629, 1, '2020-06-18 15:30:38', '2020-06-18 15:30:38', '333792e8-7809-4a10-9bc4-49cc204914e2') in .../application/vendor/yiisoft/yii2/db/Schema.php:674
Stack trace:
#0 .../application/vendor/yiisoft/yii2/db/Command.php(1298): yii\db\Schema->convertException(Object(PDOException), 'INSERT INTO `re...')
#1 .../application/vendor/yiisoft/yii2/db/Command.php(1093): yii\db\Command->internalExecute('INSERT INTO `re...')
#2 .../application/vendor/craftcms/cms/src/services/Relations.php(110): yii\db\Command->execute()
#3 .../application/vendor/craftcms/cms/src/fields/BaseRelationField.php(746): craft\services\Relations->saveRelations(Object(craft\fields\Assets), Object(craft\elements\Entry), Array)
#4 .../application/vendor/craftcms/cms/src/fields/Assets.php(546): craft\fields\BaseRelationField->afterElementSave(Object(craft\elements\Entry), true)
#5 .../application/vendor/craftcms/cms/src/base/Element.php(2559): craft\fields\Assets->afterElementSave(Object(craft\elements\Entry), true)
#6 .../application/vendor/craftcms/cms/src/elements/Entry.php(1301): craft\base\Element->afterSave(true)
#7 .../application/vendor/craftcms/cms/src/services/Elements.php(2166): craft\elements\Entry->afterSave(true)
#8 .../application/vendor/craftcms/cms/src/services/Elements.php(531): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, false, true)
#9 .../application/vendor/craftcms/guest-entries/src/controllers/SaveController.php(137): craft\services\Elements->saveElement(Object(craft\elements\Entry))
#10 [internal function]: craft\guestentries\controllers\SaveController->actionIndex()
#11 .../application/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 .../application/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#13 .../application/vendor/craftcms/cms/src/web/Controller.php(178): yii\base\Controller->runAction('', Array)
#14 .../application/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('', Array)
#15 .../application/vendor/craftcms/cms/src/web/Application.php(291): yii\base\Module->runAction('guest-entries/s...', Array)
#16 .../application/vendor/craftcms/cms/src/web/Application.php(559): craft\web\Application->runAction('guest-entries/s...', Array)
#17 .../application/vendor/craftcms/cms/src/web/Application.php(270): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#18 .../application/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#19 .../application/web/index.php(21): yii\base\Application->run()
#20 {main}
Additional Information:
Array
(
    [0] => 23000
    [1] => 1452
    [2] => Cannot add or update a child row: a foreign key constraint fails (`databasename`.`relations`, CONSTRAINT `relations_targetId_fk` FOREIGN KEY (`targetId`) REFERENCES `elements` (`id`) ON DELETE CASCADE)
)

Submits fine if no image selected.

from guest-entries.

wallacio avatar wallacio commented on August 29, 2024

Haha - I just found this out too, was about to post my solution!!

from guest-entries.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.