Having trouble to upload image with form insert action

Hi, I have a form which contain some text input, date picker and a file upload input. I want to submit the form and get the image name along with text fields and date picker value into the database table. Also want the image to be uploaded into a folder inside my server. I have created the form and created a insert action and then i have created steps for database insert and file upload, but which isn’t worked as i want… i do not want to have an upload button to upload image first. i want to have one submit button and then all inputs has to be posted to database also image uploaded to the folder. Please help me how can i make it work…?
please sea the link here for my form fields: http://booking.webonmaster.com/admin/insert-movies.php

I used that. make sure your only one form tag goes over your whole input fields, upload fields etc. make/change your button at the end and change type to “submit”. sadly this isnt default. then select the server action you created by selecting the form on right panel. now on left panel select the same server action and below on GLOBAL search your formpage and read in all the input fields so it will be shown under POST above. On server Actions add all the steps together in one. I would go with image steps first and then with mysql insert step. This way you can pass image values to your sql.

but there are good tutorials. so no need to explain it like me :laughing:

Please check the documentation: Inserting Uploaded File Names in a Database

i have followed the same steps but didn’t work for me, i have made file upload action and then made the insert action under one server action for the form. also changed the $_POST variable for the image as File. and then i have given the insert action option accordingly also did the image name for the value from POST variable.
Still i get server error 500. what cause this?? any idea…

@thines Server 500 error sounds like you have not enabled debug mode in php.ini.

do that if not done and post REAL error via debug window from your browser. (how to debug is shown here on forum post)

here is the error that i get…

{"code":"23000","file":"\/home\/webonmas\/booking.webonmaster.com\/dmxConnectLib\/lib\/db\/Connection.php","line":82,"message":"SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null","trace":"#0 \/home\/webonmas\/booking.webonmaster.com\/dmxConnectLib\/lib\/db\/Connection.php(82): PDOStatement->execute()\n#1 \/home\/webonmas\/booking.webonmaster.com\/dmxConnectLib\/modules\/dbupdater.php(38): lib\\db\\Connection->execute('INSERT INTO `Mo...', Array)\n#2 \/home\/webonmas\/booking.webonmaster.com\/dmxConnectLib\/lib\/App.php(159): modules\\dbupdater->insert(Object(stdClass), 'insertMovie')\n#3 \/home\/webonmas\/booking.webonmaster.com\/dmxConnectLib\/lib\/App.php(128): lib\\App->execSteps(Object(stdClass))\n#4 \/home\/webonmas\/booking.webonmaster.com\/dmxConnectLib\/lib\/App.php(98): lib\\App->execSteps(Array)\n#5 \/home\/webonmas\/booking.webonmaster.com\/dmxConnectLib\/lib\/App.php(71): lib\\App->exec(Object(stdClass))\n#6 \/home\/webonmas\/booking.webonmaster.com\/dmxConnect\/api\/MovieAction\/fileUpload.php(8): lib\\App->define(Object(stdClass))\n#7 {main}"}
  1. either in your DB make column name that it can have NULL

  2. or send a value. But for testing manually add in your sqlinsert a fake value in your „name“ column.

You are trying to insert a record when your database field name requires a value.
You are probably not sending a value to it.

1 Like

Yes i have fixed the issue now… thanks