- ellie123Asked 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?
- ellie123Answered on August 06, 2014 at 12:51 PM
- ellie123Answered on August 06, 2014 at 01:47 PM
- JotForm SupportMike_TAnswered on August 06, 2014 at 03:49 PM
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.
- ellie123Answered on August 22, 2014 at 03:12 PM
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...
- ellie123Answered on August 22, 2014 at 03:18 PM
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...
- JotForm SupportWelvinAnswered on August 22, 2014 at 05:09 PM
Your file in Pastebin is private. Please send it to our support email instead in text format: firstname.lastname@example.org.
Maybe, a default transparent image is possible. Based on this URL:
- ellie123Answered on August 22, 2014 at 06:11 PM
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.
- JotForm SupportjonathanAnswered on August 22, 2014 at 08:54 PM
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.
- ellie1234Answered on August 23, 2014 at 12:23 AM
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?
- JotForm SupportEltonCrisAnswered on August 23, 2014 at 06:36 AM
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!
- ellie123Answered on August 23, 2014 at 09:49 AM
Thank you Elton....you are amazing.
- HalganAnswered on August 03, 2015 at 07:38 AM
- dhgmAnswered on May 05, 2016 at 03:24 AM
- JotForm SupportChriistianAnswered on May 05, 2016 at 03:41 AM
@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/