What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

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.


  • Profile Image

    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?

    Thank you,

    Ellie

     

    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?

    upload field file upload field blank space
  • Profile Image

    Answered by ellie123 on August 06, 2014 at 12:51 PM
  • Profile Image

    Answered by ellie123 on August 06, 2014 at 01:47 PM
  • Profile Image
    JotForm Support

    Answered by Mike_T 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.

    Please provide us with the form Name/ID, and share the Thank You Page code via some text sharing tool (e.g. http://pastebin.com/, http://pastie.org/ or http://code.re/)

    Thank you.

  • Profile Image

    Answered by ellie123 on August 22, 2014 at 03:12 PM

    Hello -

    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:

    http://undercoverdiner.net/mysteryform/oi1009/

    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...

  • Profile Image

    Answered by ellie123 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...

  • Profile Image
    JotForm Support

    Answered by Welvin 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: support@jotform.com.

    Maybe, a default transparent image is possible. Based on this URL:

    https://s3.amazonaws.com/jufs/ellie123/42075761645963/283176625851824119/defaultnonimage.jpg

    Thank you!

  • Profile Image

    Answered by ellie123 on August 22, 2014 at 06:11 PM

    Oops....Sorry...blonde moment!

    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.

    Thank you!

  • Profile Image
    JotForm Support

    Answered by jonathan on August 22, 2014 at 08:54 PM

    Hi Ellie,

    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 .

    User Guide: http://www.jotform.com/help/57-Smart-Forms-Using-Conditional-Logic

    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.

    Thanks.

     

  • Profile Image

    Answered by ellie1234 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?

  • Profile Image
    JotForm Support

    Answered by EltonCris on August 23, 2014 at 06:36 AM

    Hi,

    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!

     

  • Profile Image

    Answered by ellie123 on August 23, 2014 at 09:49 AM

    Thank you Elton....you are amazing.

  • Profile Image

    Answered by Halgan  on August 03, 2015 at 07:38 AM

    if(empty($img_name))`{

    $img_name=$_FILES['default_img'];

    $img_name='default_img.jpeg';

    <img src=../path/img/default_img.jpeg>

    }

  • Profile Image

    Answered by dhgm  on May 05, 2016 at 03:24 AM

    fhdlask

  • Profile Image
    JotForm Support

    Answered by Chriistian 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/ 
    Regards.