Forums

Files corrupt using download action

stepd 10 Jan, 2015
Hi, I'm using Chronoforms V5 and I'm getting corrupted files when using the download action. I've tested with pdf and jpg so far, and it happens in all browsers I've checked (FF, IE, Chrome) as well as on other people's computers using different ISPs.

It originally happened on a complicated multi-page form, but I created a new form with just a download button and action, and I'm getting the same results. The files are fine on the server and open fine via ftp. When I use the form to download a 1.6MB pdf, the firefox download cue shows the file size correctly, but when it reaches my desktop, the file is only 4KB and I get the message "The root object is missing or invalid" in Acrobat. When I download a jpg, Photoshop doesn't recognize the file.

I tested with a couple of PHP download scripts (Smart File Download and PHP Easy downloader), and the files download and open fine using those scripts. Any ideas what the problem could be?
GreyHead 10 Jan, 2015
Hi stepd,

I've no real idea, and haven't' seen this reported before in the forums here.

I wonder what is being downloaded - please look at the 4kb file in a text editor and see what the contents are - I am guessing that they may be the HTML content of the page instead of the file.

Bob
stepd 10 Jan, 2015
I forgot to mention that I did actually open the pdf file in a text editor, and it does have binary info in it. Looks like the beginning of a pdf header then has about 50 null lines. I'll try to attach it as a text file to this post.
GreyHead 12 Jan, 2015
Hi stepd,

Hmm - the file looks a bit like a PDF but clearly is missing most of the content. Hard to know what is happening. Please post a link to the form so I can take a quick look.

Bob
stepd 12 Jan, 2015
To remove distractions, here's a stripped down page with just a form with a submit button:

http://pffc-online.com/downloadtest
GreyHead 14 Jan, 2015
Hi stepd,

I tried to look but the site is giving me "Database connection error (2): Could not connect to MySQL."

Bob
stepd 14 Jan, 2015
You probably just happened to check during a run of indexer bots. That error can appear on occasion if a bunch of them hit the site at the same time (thousands of articles on the site). The site is hosted on a VPS at inmotion. Unfortunately, not related to the download problem.
GreyHead 16 Jan, 2015
Hi stepd,

Sorry, no bright ideas here. I see the same as you - the full file size shows, then the download is cut off.

Does it work if you create a download link and show that instead of the immediate download?

Bob
stepd 16 Jan, 2015
Yeah, it's definitely strange. Pretty much everything else I've tried works (direct links, external third-party php scripts, etc.). There must be some kind of problematic interaction between the Chronoforms download action and the way this particular server is set up or something. On the original form, I just ended up using the hidden iframe trick where the user clicks the button, javascript changes the iframe source to an external php script (Smart File Download) with the file name appended to the URL, and that script forces the save as dialog in the browser. It's a roundabout way of doing it, but at least it's working. The main thing is, I don't want the location of the file to be obvious to the user since they have to fill out a form first to download the file, so using a form action that doesn't expose the file folder In the page source is important.
MinMatch 08 Mar, 2015
I'm curious if you ever found an answer to this? I'm having almost the exact same problems with a PDF file on my site. I can view the PDF in the browser if I link to it, and I can e-mail the file to myself and open it just fine, but if I download it, it says the file is corrupt.

You can access the form at http://www.ministermatch.com/congregations/guided-search and just fill out the "Ready to Learn More" form on the right hand side.

The PDF file was generated out of Apple Pages. I have both tried version of the file that were exported to PDF and versions that were "printed" to PDF using the built in Mac save to PDF function on the print screen.
Max_admin 08 Mar, 2015
What do you have in the setup section before the "Download" action ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
MinMatch 08 Mar, 2015
Hi Max,

On Load
Load Captcha
HTML (Render Form)

On Submit
Check Captcha
On Success (blank)
On Fail
Event Loop

Handle Arrays
Custom Code (Sets the Email and Linked File)

Email (to the admin)
Email (to the user with a copy of the file set in Custom Code)

Event Loop (calls On D1)

On D1
HTML (Render Form) - Loads Thank you screen with link for download button and a link to open the file directly in browser (based on the custom code above).
When the download button is clicked it calls D2.

On D2
File Download

Process wise, everything seems to work fine. I get the PDF in the e-mail and can open it. I can click the link on the D1 screen to open the PDF in the browser. I can click the link for the download button and the file downloads but shows up as corrupt.

In all 3 delivery methods, I'm pulling the same file from the same source.

I'm running this on ChronoForms 5 on a Joomla 3.4 server.
Max_admin 09 Mar, 2015
Try to add this to the D2 link:
&tvout=ajax


Does it help ? if not then please copy and paste the full link to D2 here, the one used in the download button!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
MinMatch 09 Mar, 2015
Sorry Max but that didn't work. I added that to the end of my URL but when I click on the download button, the thank you message disappears but nothing downloads now. Without the
&tvout=ajax
piece, the file will download but is damaged and will not open. With the ajax piece, the file doesn't even download.

Here is the link used in the FileDownlaod action for D2. /home/minmatchadmin/public_html/images/documents/7GreatMythsAboutSearchFirms.pdf

The domain name is www.ministermatch.com
Max_admin 09 Mar, 2015
How do you have the download button set up ? is it a "link" to the D2 event or its a submit button ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
MinMatch 09 Mar, 2015
The Button on D2 is setup as a submit button.

The D1 HTML form is Form Method: File; AJAX Submit: No

I tried changing the AJAX Submit type to "yes" while spending the &tvout=ajax to the url but that didn't seem to work either.

Don
Max_admin 09 Mar, 2015
Hi Don,

No, AJAX will not work here.

We need a link to test the download event, which is the form link + "&event=D2&tvout=ajax"

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
MinMatch 09 Mar, 2015
Sorry Max,

I'm not sure what you are asking me to do. I created a manual link on the D1 thank you page called "test" that links to "href=images/documents/7GreatMythsAboutSearchFirms.pdf&event=D2&tvout=ajax" but that doesn't seem to trigger the download event... What am I missing?
Max_admin 09 Mar, 2015
What's the link to your form ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
MinMatch 09 Mar, 2015
The link to the form is http://www.ministermatch.com/congregations/guided-search (it is the "ready to learn more form on the right hand side"
Max_admin 09 Mar, 2015
Ok, this is the link executing the D2 event:
http://www.ministermatch.com/index.php?option=com_chronoforms5&chronoform=7MostCommonMythsAboutSearchFirms&event=D2

but it returns nothing, which means that your "D2" event doesn't exist or is not configured correctly or maybe the file was not found.

Please check that or post a screenshot for the setup section in your form!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 10 Mar, 2015
Hi MinMatch,

I also noticed that your form name starts with a 7 - that may be causing problems; please try changing it to start with a letter.

The name may be used as a variable name in PHP and they can't start with digits.

Bob
MinMatch 10 Mar, 2015
Thanks Max and GreyHead,

I have renamed the form name and underlying PDF to remove all names that start with a numeral but I'm still having the problem.

One key piece of information that I have just learned is that when I use the File Downloader with the PDF, some of my site's <div> codes are being appended to the beginning of the PDF file. I opened the PDF in a text editor and the first few lines read as:

<div class="module_round_box_outer">

<div class="module_round_box">

<div class="s5_module_box_1">
<div class="s5_module_box_2">
<div class="s5_outer">
%PDF-1.3

Those are classes used in my site template. If you look at the same file, pulled from the same source when it is e-mailed to me from Chronoforms and that extra content is not in there.

Max had asked for a screenshot of my Setup tab but your forum editor will not let me upload a file or picture. Here is a link to a screenshot of the setup. http://www.ministermatch.com/images/home/Screen%20Shot.png.

Don
Max_admin 10 Mar, 2015
Ok, its "d2", please try this link after updating the form name:

http://www.ministermatch.com/index.php?option=com_chronoforms5&chronoform=7MostCommonMythsAboutSearchFirms&event=d2

Does it work ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
MinMatch 10 Mar, 2015
Hi Max,

I put the link that you showed above on Page 2 of my form (the thank you page) and it works fine. The file downloads and is not corrupt. When I click the "download" button that triggers the Chronoforms file download action, the file is corrupt and has that extra content that i mentioned in an earlier post.

Please advise on the best way to resolve.
Max_admin 10 Mar, 2015
Just use the link, you can style it to look like a button this way:

<a class="btn btn-success" href="link goes here">Download</a>
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.