Is it possible to upload single image and multiple images info into different tables with one server action?

Hello,

If I had this page, is it possible to upload single image and multiple images info into different tables with one server action?

if possible, I would like to use the data of inserted record of the single image for inserting multiple images data into the different table. How can I do it? I especially got stuck about this multiple images’ file name inserting part.

Thanks,

This may help you

2 Likes

Thank you for sharing a vide link.

I followed your instruction but it doesn’t work completely.

Entire server action is below.

It is working well by “Database Insert: insert1”.
But there should be some mistakes in the later action steps.

This is what I did.

Could you please find where I made mistakes?

Thanks in advance!

Is it that both of the database insert steps work OK?

Are both of the file uploads and saves working OK?

insert1 works.
insert2 doesn’t work at all.
upload1 works, save image of image1 works.
upload2 doesn’t work.

Thanks,

Turn on Debug Mode

Using Chrome to load the site, right click the page and choose Inspect

image

Open the Console tab

When you now go through the exercise of uploading images, you should see the error that is occurring.

Thanks

I got this error. The error seems about the file “upload2”.

I yet can’t upload files of “upload2” and can’t do “insert2” either.

I see this error that states that the images could not be found

With a bit of luck @Teodor may be able to throw some light on this.

For me it was very late last night and getting tired.

Back in the morning, I suddenly thought that it may be the input that is causing the problem. Please paste the code for form so that I can have a look at it.

Good morning,

Thanks a lot for continuous support! Here is the form code. Please have a look at it.

<form id="entry_application" method="post" is="dmx-serverconnect-form" action="dmxConnect/api/Data/competition_entry_application_submit.php"
								dmx-on:success="entry_application.reset();browser1.goto(query.permalink+'/'+query.eventsequencial+'/entry/');toasts1.show({message: 'Your application is successfully submited!', delay: 500000})"
								dmx-on:submit.prevent="run({'bootbox.confirm':{title:'Submit',message:'Are you ready to submit your application?',buttons:{confirm:{label:'Yes, I am!',className:'btn-primary'},cancel:{label:'No, I\'m not!',className:'btn-dark'}},then:{steps:{run:{action:`session1.set(\'idstyleapplicationmaster\',serverconnect1.data.query_event_info.idstyleapplicationmaster);session1.set(\'idevent\',serverconnect1.data.query_event_info.idevent);entry_application.submit(true)`,name:'competition_entry_application_submit'}}},else:{steps:{'bootbox.alert':{title:'Error',message:'There is an error, please contact the administrator if you can not submit your application.'}}},name:'confirmsubmit'}})"
								dmx-on:error="browser1.alert('You could not submit your application, please try again.')">
								<div class="form-group row">
									<div class="col-sm-12">
										<div class="d-flex">
											<div class="d-block">
												<h5>Upload Image (for thumbnail)</h5>
											</div>
											<div class="d-block text-primary">
												<h5>*</h5>
											</div>
										</div>
									</div>
									<div class="col-12">
										<input type="file" class="form-control" id="input1" name="input1" aria-describedby="input1_help" accept=".jpg,.png,.jpeg" required="" data-rule-maxsize="3000000">
										<small id="input1_help" class="form-text text-muted" style="color: #a00000 !important;">Select here your image for upload. .jpg .jpeg and .png are accepted.</small>
									</div>
								</div>
								<div class="form-group row pt-3" dmx-show="(serverconnect1.data.query_event_info.idstyleapplicationmaster == 2)">
									<div class="col-sm-12">
										<div class="d-flex">
											<div class="d-block">
												<h5>More Images Upload</h5>
											</div>
											<div class="d-block text-primary">
												<h5>*</h5>
											</div>
										</div>
									</div>
									<div class="col-12">
										<input type="file" class="form-control" multiple="true" name="input2" aria-describedby="input2_help" data-rule-maxfiles="5" data-rule-maxtotalsize="15000000" data-rule-minfiles="1" id="input2">
										<small id="input2_help" class="form-text text-muted" style="color: #a00000 !important;">Select here your image for upload. .jpg .jpeg and .png are accepted. 5 files are acceptable.</small>
									</div>
								</div>
								<div class="form-group row pt-3" dmx-show="(serverconnect1.data.query_event_info.idstyleapplicationmaster == 3)">
									<div class="col-sm-12">
										<div class="d-flex">
											<div class="d-block">
												<h5>Video Link Upload</h5>
											</div>
											<div class="d-block text-primary">
												<h5>*</h5>
											</div>
										</div>
									</div>
									<div class="col-12">
										<input id="input3" name="input3" type="url" class="form-control" placeholder="https://" data-rule-url="">
										<small id="input3_help" class="form-text text-muted" style="color: #a00000 !important;">Submt your video link. Please make sure if it is the correct one.</small>
									</div>
								</div>
								<div class="form-group row pt-3" id="input4_group" is="dmx-radio-group">
									<div class="col-sm-10">
										<div class="d-flex">
											<div class="d-block">
												<h5>Entree Name</h5>
											</div>
											<div class="d-block text-primary">
												<h5>*</h5>
											</div>
										</div>
										<div class="form-check">
											<input class="form-check-input" type="radio" value="1" id="input4_1" style="margin-left:-15px;" name="input4">
											<label class="form-check-label" for="input4_1">Your Name (registered)</label>
										</div>
										<div class="form-check">
											<input class="form-check-input" type="radio" value="0" id="input4_2" style="margin-left:-15px;" name="input4">
											<label class="form-check-label" for="input4_2">Account Name</label>
										</div>
										<small id="input4_help" class="form-text text-muted" style="color: #a00000 !important;">Select one you prefer.</small>
									</div>
								</div>
								<div class="form-group row pt-3">
									<div class="col-sm-12">
										<div class="d-flex">
											<div class="d-block">
												<h5>Entree Description</h5>
											</div>
											<div class="d-block text-primary">
												<h5>*</h5>
											</div>
										</div>
									</div>
									<div class="col-sm-12">
										<textarea id="input5" class="form-control" name="input5" maxlength="1000" required=""></textarea>
									</div>
								</div>
								<div class="form-group row pt-3">
									<div class="col-sm-12">
										<p>If you agree with <a href="/termsofservice/" target="_self">terms of use</a> and <a href="/privacy/" target="_top">privacy policy</a> of our services, please
											press
											entry button below.</p>
									</div>
								</div>
								<div class="form-group row">
									<div class="col-sm-12 col w-auto center">
										<button id="btn2_submit" type="submit" class="btn btn-primary w-30">ENTRY</button>
									</div>
								</div>
							</form>

You need to make the input an array by adding square brackets to the name, as in

1 Like

I did it, but it doesn’t change.

I can not upload files of input2 at all, can not insert the data of input2 into db either.

Please have a look at

Thanks a lot!!

Now it worked!

I just changed the order of steps after adding a bracket with input2.

1 Like