How can I make the uploaded image in the submitted form by a user appear on the homepage of my website?

  • Profile Image
    Scott
    Asked on February 01, 2012 at 03:15 PM

    So as the title suggests...I am using Yola to create my website.  What i am looking to be able to do is Have a spot on my homepage where users can upload an image.  I want this image to then be displayed on my homepage as soon as they click the submit button. 

     

    Along with this it would also be nice for users to be able to rate the picture, share(fbook, twitter, etc) the picture, and rate the picture.

     

    Is this possible with your tool? Any help is greatly appreciated!

  • Profile Image
    fxr
    Answered on February 01, 2012 at 07:27 PM

    While a lot of the functionality in your brief is considerable beyond the core scope of JotForm, it certainly is possible to make use of JotForm to achieve it. 

    I will give an outline of how I would see it working. 

    1. Create your upload form on JotForm.

     

    2. Go to www.jotform.com/myforms

    3. Click on the new form and click the submissions icon.

    4. Click on the options cog on the right hand side and select Send Uploads to FTP

     

    5. Insert your servers FTP settings:

     

    6. Enter the folder on the server where you want the uploads to go to and click finish:

     

     

    Thats the images now being uploaded to a location on your server. 

     

    Now its the difficult part, this requires some coding. 

     

    7. Your home page would need some code to read the directory where these JotForm uploads are going to and then show them on your homepage. 

    This is a very basic example of such code:

    <?

    $directory = "FTPupload/";

    //get all image files with a .jpg extension.

    $images = glob($directory . "*.jpg");

    //print each file name

    foreach($images as $image)

    {

    echo "<img src='$image' height='10%' width='10%'>";

    }

    ?>

    NOTE: this code only looks fors jpg files. 

    8. I would then use a Custom URL as a thankyou page to redirect the user back to my home page. 

     

     

     

    You can see an example of this functionality working here

     

    Obviously, there would quite some work you would need to do with the php to get things positioned and looking right on your homepage. But this very basic example shows that what you are trying to achieve is possible. 

     

    Rating and sharing of pictures from your webpage is beyond the scope of JotForm, but is doable with some code. 

     

    Hope that helps.