Inserting Uploaded File Names in a Database

Storing the uploaded file name in your database is an easy task in Server Connect.
You already know HOW TO UPLOAD A FILE so this will be just an addition to it, showing how to store the uploaded file name in your database.

You already have your upload page, with the upload server action set up. Now we will just extend the existing server action. Open the server connect panel:

Right click the file upload step:

Open the Database Actions menu and select Database Connection:

Setup your database connection or select one if you already defined it. Then right click the database connection step:

Open the database actions menu and select Database Insert:

Then click the Insert Options button:

Select the table where you want to store your file info:

Double click the value field, for the column you want to insert the file info into. Then click the dynamic data picker:

You can either store just the file name (1) or the file URL (2).
Storing the file name only, will require to manually add the path to the file on the pages where you are going to use this info and use a dynamic value for the file.
Storing the URL will allow you to bind the whole url to the file on your pages.

It’s up to you to decide which one to store:

We prefer to store just the file name, as it’s a more flexible solution:

Click OK:

Save your server action:

And you are done.

WapplerPrevious   WapplerNext


Hi Teodor,

Firstly, thank you for providing these very useful file upload tutorials. I have also added a table on the same page which lists the uploaded files and provides the download links. However, I have not found a way to auto refresh the table after the file has been uploaded. Is there some kind of auto refresh option?

Thanks and best regards,

Hi Brian,
On success of the upload action, reload the server action listing the files :slight_smile:

Of course - now that you say it like that - seems obvious. Thanks again! :smile:

1 Like

7 posts were split to a new topic: Can’t see upload step properties on insert

This tutorial says;

We prefer to store just the file name, as it’s a more flexible solution

Can you provide an example or two of how saving just the file name to the database would be a more flexible solution than saving the file URL?


Hello Eddie,
This is useful if you for example are using image upload, which creates several image sizes and you don’t want to store every version (size) in your database. So let’s say you upload, resize and save 3 versions: image.jpg, thumb_image.jpg and square_image.jpg

Then you can always call the same filename from your database and add add the path and prefixes where needed in your page template:

<img dmx-bind:src="/path/to/images/{{img}}">
<img dmx-bind:src="/path/to/images/thumb_{{img}}">
<img dmx-bind:src="/path/to/images/square_{{img}}">

Same if you store them with the same name in different folders. Then you just change the path in the template and always call the same name:

<img dmx-bind:src="/path/to/images/{{img}}">
<img dmx-bind:src="/path/to/images/thumb/{{img}}">
<img dmx-bind:src="/path/to/images/square/{{img}}">
1 Like

Thank you, @Teodor. It makes sense to me now. Much appreciated.

1 Like