TCPDF fails when there is no file upload - looking for ways around it

DrSmith69 26 Jul, 2019
Hi all,

So i have added a image file upload to my server which then writes onto my TCPDF file and stores locally. All works perfectly when there is a physical file uploaded, however, for obvious reasons the TCPDF fails when there is no file upload as it cannot find the non-existent image file.

I have tried to seperate the TCPDF to store differently depending on file upload success/failure - however, file upload fail is not triggered by not having a file uploaded so therefore that option does not work.

Do you have any ideas around this, or a little trick I can implement to ensure even though no file is uploaded the TCPDF still generates without including the file upload?

Many Thanks,
healyhatman 26 Jul, 2019
Use a switch. If {var.empty:fileuploadaction} is true then return probably just "No image uploaded" but if false then put your image tag code. Use {var:switchname} in your TCPDF action in place of the image tag you have now.
DrSmith69 26 Jul, 2019
Hi Healy,

Thanks very much - can you advise where i am falling short - I can't attach a screenshot, upload is not working on the forum for me.

My Upload is called Upload93,
My switch is called tcpdfswitch

In my switch data provider i have: {var.empty:upload93}

In my values i have:

1:"No passport uploaded"
2:"passport found"

on my TCpDF i have:
<h3 style="text-align: center;">{var:tcpdfswitch}</h3>

My Debug gives me this:

[upload93] => Array
        (
            [path] => /home/iregcdvg/public_html/components/com_chronoforms6/chronoforms/uploads/
            [file95] => Array
                (
                    [extensions] => Array
                        (
                            [0] => jpg
                            [1] => jpeg
                            [2] => png
                            [3] => gif
                            [4] => pdf
                            [5] => doc
                            [6] => docx
                            [7] => txt
                            [8] => zip
                        )

                    [info] => File is not present.
                )

            [var] => Array
                (
                )

        )

    [tcpdfswitch] => Array
        (
            [finished] => 1
            [var] => 
        )
However, nothing prints on my tcpdf, where have I gone wrong?

Many Thanks,
healyhatman 26 Jul, 2019
Answer
You should have values of true: and false: and true means the file is empty and therefore was NOT uploaded
DrSmith69 26 Jul, 2019
Working like a dream, thank you very much🙂
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger