How to Set A Default Image in File Upload Field?

  • ellie123
    Asked on August 6, 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?

  • ellie123
    Replied on August 6, 2014 at 12:51 PM
  • ellie123
    Replied on August 6, 2014 at 1:47 PM
  • Mike_T Jotform Support
    Replied on August 6, 2014 at 3: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://pastie.org/,, or http://code.re/)

    Thank you.

  • ellie123
    Replied on August 22, 2014 at 3: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...

  • ellie123
    Replied on August 22, 2014 at 3: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...

    How to Set A Default Image in File Upload Field? Image 1 Screenshot 20

  • Welvin Support Team Lead
    Replied on August 22, 2014 at 5: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!

  • ellie123
    Replied on August 22, 2014 at 6: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: onDISABLEDerror="this.style.display='none'"

    So, your image link would look something like this:

    <img src="https://yourimagelink.jpg" alt="myalttag0" width="250" onDISABLEDerror="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!

  • jonathan
    Replied on August 22, 2014 at 8: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)

    How to Set A Default Image in File Upload Field? Image 1 Screenshot 20

     

     

    Hope this help. Inform us if you need further assistance.

    Thanks.

     

  • ellie1234
    Replied 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?

  • Elton Support Team Lead
    Replied on August 23, 2014 at 6: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!

     

  • ellie123
    Replied on August 23, 2014 at 9:49 AM

    Thank you Elton....you are amazing.

  • Halgan
    Replied on August 3, 2015 at 7:38 AM

    if(empty($img_name))`{

    $img_name=$_FILES['default_img'];

    $img_name='default_img.jpeg';

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

    }

  • dhgm
    Replied on May 5, 2016 at 3:24 AM

    fhdlask

  • Chriistian Jotform Support
    Replied on May 5, 2016 at 3: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.