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).
What are your server connect steps and what would you like to skip?
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
So you just don’t want to insert empty string in the database? Or is there another issue?
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
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.
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?
I have created a guide for this, from the DW era, but more or less it is the same proccess. Check below.
Hope it helps.
Thank you!
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.