Skip the file upload


#1

I made a page to insert a file into database and upload/resize the image. I finally got it working but if I do not upload an image it fails. How do I tell it to skip if there is no file uploaded (I’m probably missing a checkbox).


#2

What are your server connect steps and what would you like to skip?


#4

database connection
file upload
load image
resize image
save image
set value
database insert

Sometimes I don’t have a photo to upload so the default entry in the database is a standard picture. I


#5

So you just don’t want to insert empty string in the database? Or is there another issue?


#6

Primarily, I’m not sure why it fails.

I guess I should have it insert a default text into the field indication the standard image


#7

It fails because the load image step receives wrong path (empty value).
You should put the following steps in a condition:

file upload
load image
resize image
save image

As a condition value use the $_POST variable, which corresponds to your upload field. This way, only when there is a file selected, the upload+resize will be run.

Also in insert step you can use the “default” filter to insert your standard picture name when no upload is made.


#8

Ok, thanks, I have a few questions
so condition should be a formula like $_Post is not null? (because I just pointed it to the post and it runs the same way)

what do I do with set value?


#9

I have created a guide for this, from the DW era, but more or less it is the same proccess. Check below.

https://www.evernote.com/shard/s593/sh/bd84142e-61bd-447d-b725-cdb793593e24/1d4fc5f660ab9aff404927bf827c8c5f

Hope it helps.
Thank you!


#10

I got a bit confused by the difference in the interface between DW era (I never used it) and Wappler so I ended up adding a condition that had all of the file upload goodies in there if there was a file selected and a regular database insert if there was not. In that regular insert I set the file name to a default image but still used the entries from the rest of the form.