brad
August 13, 2024, 4:06pm
1
I have a simple upload document form that uploads a document and inserts a record in the database. This works 95% of the time.
However, On occasion it inserts a null value in the document name field. I can't pin down why or when this happens. So what I would like to do is only insert and upload if the upload1.name
is not null. Is this possible?
Can you not just wrap the db insert action inside an if step?
brad
August 13, 2024, 4:18pm
3
Well, that's what I thought. But upload1.name
isn't available as a condition?
Teodor
August 13, 2024, 4:23pm
4
Use a condition and check if the POST variable has a value or not:
1 Like
brad
August 13, 2024, 4:49pm
5
Thanks guys, that seems to work. I will wait and see if any more blank entries are added.
Much appreciated,
Apple
August 13, 2024, 9:50pm
6
As far as I know the name is sent by the browser so it depends on the user's browser
brad
August 13, 2024, 11:24pm
7
Interesting. I never thought it might be browser specific. I’ll have to do some more testing. Thanks @Apple
I am not in a position to test but i suspect that the name property of the Upload action is present, just not in the picker for some reason
You may be able to manually add the test 'upload.name != null' rather than using the $_POST value from the picker
Teodor
August 14, 2024, 9:44am
9
The name property is not available before the upload step Brad wanted to check:
and that is why checking the POST for a value is the solution here. If the upload input is empty the upload and inert won't run.
Fair enough, though he just wanted to prevent the database update
1 Like