JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.
We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.
How to Set A Default Image in File Upload Field?Asked by ellie123 on August 06, 2014 at 12:10 PM
How can I set a default image in my file upload field?
I don't want there to be a blank space where I am displaying my form results, so I would like to set a default image in case the user decides not to upload an image.
Can you pls tell me the best way to do this?
P.S. I should note that I am using a custom thank you page and storing my values in my MySql db...so perhaps there is a way I could do it using one of those ways?
It is most probably that you will need to adjust the Thank You Page code in order to set the default image for blank upload entries.
Please see my Custom Thank you Page Pastie Here: http://pastebin.com/imN2Jpr9
If you scroll down you'll see where I highlighted the fields I need to set a default for.
Here's what's happening...if I don't have a default image, then my page is showing a broken image link:
If you know how to get rid of the broken image border and little broken page inside then that would work, too....lol.
But, I'd rather learn how to set a default image...
If we can't use that default image, maybe I can use a transparent pixel instead? Anything else other than showing that box...just an idea
BTW...this appears to be an issue with Chrome and IE browsers. The images that are not there render perfectly in Firefox. It just shows a blank area; no box, no broken image link, etc.
(HOWEVER....brings me back to OP...I'd STILL like to learn how to set a default image in none uploaded.)
From this image you can see that Firefox renders missing images the way that I am trying to achieve, however, I understand that CSS help is most likely out of your scope of services. But, thought I'd share this anyway...
Your file in Pastebin is private. Please send it to our support email instead in text format: email@example.com.
Maybe, a default transparent image is possible. Based on this URL:
I set the Pastie to Unlisted...so try now. Sorry about that.
Okay....I think I totally simplified my support question! Now it should be right in the JotForm Support ballpark!
Good News! I figured out how to fix the border/box issue...for anyone looking for same solution. Add this to the end of your img src url: onerror="this.style.display='none'"
So, your image link would look something like this:
<img src="https://yourimagelink.jpg" alt="myalttag" width="250" onerror="this.style.display='none'"/>
NOW...I still need to learn how to set a default image on my Custom Thank You page for my File Upload Fields.
If I understand the requirement correctly, I think you can just use conditional statements to Change Thank You URL after form submission base on an option .
use this option to interchange custom Thank you page (one with default image, and another without)
Hope this help. Inform us if you need further assistance.
I don't really see how your suggestion would work....
That doesn't help me to set a default image in those image upload fields though....I can't change my custom thank you page, I have to use that custom thank you page. The one that one put in the pastie.
Isn't there a way, I can assign a default image to be used for an image field if no image is uploaded?
For instance, on the custom thank you PHP Page in the POST fields...can't I put an image URL to be used if no file is uploaded?
You can use basic short hand if/else condition, like the following.
$defaultImage = 'YOUR IMG URL HERE'; //create variable for default image
$uploadpictures6=(empty($_POST['uploadpictures6']) ? $defaultImage : $_POST['uploadpictures6']);
Create for the rest of the remaining file uploads.
Hope this helps!
Thank you Elton....you are amazing.
@dhgm This appears to be an old thread. Do you have any concerns regarding your form? Please open up a new thread so we may better assist you. You can contact us by following this link: https://www.jotform.com/contact/