Insert Record only if upload name exsists

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?

Well, that's what I thought. But upload1.name isn't available as a condition?

Use a condition and check if the POST variable has a value or not:

1 Like

Thanks guys, that seems to work. I will wait and see if any more blank entries are added.

Much appreciated, :beers:

As far as I know the name is sent by the browser so it depends on the user's browser

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

The name property is not available before the upload step :slight_smile: 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