How to display an indication that no files were uploaded if its not successful somehow?

  • Profile Image
    bluewhaleshark
    Asked on March 03, 2013 at 09:17 PM

    I created a form for my students to upload their assignments. I put the upload as a "required". But due to unstable internet connection in the college, sometimes the files are not uploaded. There was no indication saying that the upload was successful or not. Thankfully I found a thread in jotform showing how to modify the thank you page so that the data sent will be displayed in the thank you page. So if there was no files uploaded, nothing will be displayed in "Assignment files". What I would prefer is some sort of message such as "Assignment file: NO FILES UPLOADED" so that the students would see it clearly. Is there any way to do that? Your help is really appreciated.

  • Profile Image
    EltonCris
    Answered on March 04, 2013 at 01:43 AM

    Hi,

    This might be possible with "How to Post Submission Data to Thank You Page" and use custom PHP scripts to create a condition would replace the upload field value (like "No Files Uploaded") when "upload field is empty". Note quite sure about this but I'll give it a try later and provide to you the PHP script if I can come up with a solution. I'll get back to you later today or tomorrow morning (GMT + 8).

    Thanks!

  • Profile Image
    EltonCris
    Answered on March 04, 2013 at 10:23 PM

    Hello,

    Sorry for the delay. If you are still willing to the solution, I have come up with a custom PHP scripts that creates such function. Here's how:

    1. Get the full thank you page source here with PHP scripts already added: http://pastie.org/6386430#1-10,54,58,62,66,71-82

    2. Copy and paste that into your notepad and save it as thankyou.php or to any file name you'd prefer, just be sure to save it as php file.

    3. Upload the php file to your server or to any hosting you have.

    4. Get the php file URL and set it as your form's thank you custom URL.

    a. Click on "Setup and Embed" tab on the form builder toolbar

    b. Click on "Thank You" button on toolbar

    c. Select "Custom URL" and click "Next"

    d. Paste the php file URL e.g.

        

     

    -----

    Demo Submit with files and no files, you'll be able to see the difference. http://www.jotformpro.com/form/30627757709969?

    -----

    Conditional PHP Script for your reference.

    <?php 

    if( (empty($files)) || ($files===NULL)){

    $nofile = "No Files Uploaded";

    echo '<span style="color:red;font-weight:bold";>'.$nofile.'</span>';

    }

    else{

    foreach($files as $x=>$x_value)

       {

       echo '<a target="_blank" href="https://www.jotform.com/uploads/bluewhaleshark/'.$formid.'/'.$submissionid.'/'.$files[$x].'">'.$files[$x].'</a>';

       echo '<br>';

       }

    } ?>

    Feel free to let us know if you have further questions about this. Thanks!

  • Profile Image
    bluewhaleshark
    Answered on March 04, 2013 at 10:45 PM

    Thanks a lot! That was awesome. I tried your demo and it was exactly as I wanted. Unfortunately, i don't have my own server or hosting. Can't I just copy the php script into the thank you page in jotform?

  • Profile Image
    EltonCris
    Answered on March 05, 2013 at 12:58 AM

    Hi,

    One of my colleague recommended http://www.000webhost.com/ as it's good when it comes to free hosting or www.awardspace.com. You can give it a try if you'd like to host the files on your own.

    Or, I have hosted it from JotForm's file repository, please check your form now as I have set it for your convenience. This is the thank you page URL https://shots.jotform.com/thankyou.php.

    You can make a test with your form now. Thanks!

  • Profile Image
    bluewhaleshark
    Answered on March 05, 2013 at 02:21 AM

    Wow! That's great. You are really fast. But will I be able to use the repository for long? I have yet another question actually. What if I want to upload 3 files but only one of them is successful? Is there a way to detect those files that are not successful? Thank you for your respond.

  • Profile Image
    Welvin
    Answered on March 05, 2013 at 04:14 AM

    Hi,

    My colleague Elton is not here at the moment so please let me answer your additional inquiries;

    But will I be able to use the repository for long?

    -I'm not sure about that so I suggest you to create your own via the suggested Free hosting sites.

    What if I want to upload 3 files but only one of them is successful? Is there a way to detect those files that are not successful? 

    -Still, I'm not quite sure if there's a way for this to have in a form. Let's wait for my colleague Elton's advice.

     

    Thanks

  • Profile Image
    EltonCris
    Answered on March 05, 2013 at 08:18 AM

    Thanks Welvin.

    @bluewhaleshark

    That's our official file repository so I would say files are hosted forever, though it is still wise to get a copy of the script so whatever circumstances may happen to our file repository (we do not know), you will not be affected. :)

    With regards to the other question, failed uploads will not be included when the form is submitted so it can't be detected to my knowledge. However, there is an indication (upload progress shows "failed") when a file upload is failed so I think re-uploading it is the best solution. ;)

    Thanks!