Forum

Thread tagged as: Problem, Forms

Perch Form file upload works but can't be downloaded

I have a client who was still ticking over on Perch 2.8.34 without any issues. However, it now seems that the Perch Form for their careers applications isn't quite working as it used to after they moved host from Vidahost to Tsohost (same company who merged the two together). I noticed that the root path was incorrect after the merge so the file upload wasn't working, so I fixed that - along with the permissions on the upload folder outside the website - and files now upload and submit fine. However, when viewing a response in the Admin panel of the Perch Form, the file is shown correctly (I've even checked the upload folder for the form, and they are getting uploaded fine) but the link for the file doesn't download anything? It's going to here with unique IDs for each entry: /perch/addons/apps/perch_forms/responses/detail/?id=2327&file=application_form but it's just refreshing the page and not downloading any files – any idea what's going wrong?

This is what I'm using in my template:

<perch:input type="file" id="application_form" label="Application Form or CV" accept="pdf text richtext office" required="true" />

Debug in Perch Admin on a form response before clicking file link:

Debug Message
[1] SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='9db1cfbd594cf57e1ac3914257c84f0a' LIMIT 1
UPDATE perch2_users SET userHash='7763ca89b9c77a99533a24a811c87a68' WHERE userID='1'
[40] SELECT p.privKey FROM perch2_user_privileges p
[29] SELECT * FROM (SELECT DISTINCT settingID, settingValue, userID FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID, settingValue, userID
[1] SELECT * FROM perch2_forms_responses WHERE responseID='2327' LIMIT 1
Queries: 6
Memory: 1.8855

Debug in Perch Admin on a form response after clicking file link:

ebug Message
[1] SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='4e8bc2bbe9a2e7d6c2722e93d7c691fe' LIMIT 1
UPDATE perch2_users SET userHash='c460e4eb1362185e635d8692399eac5d' WHERE userID='1'
[40] SELECT p.privKey FROM perch2_user_privileges p
[29] SELECT * FROM (SELECT DISTINCT settingID, settingValue, userID FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID, settingValue, userID
[1] SELECT * FROM perch2_forms_responses WHERE responseID='2327' LIMIT 1
Queries: 6
Memory: 1.8877
Array
(
    [type] => 8
    [message] => Trying to get property of non-object
    [file] => /var/sites/c/carelinelifestyles.co.uk/public_html/perch/addons/apps/perch_forms/modes/response.detail.pre.php
    [line] => 20
)

Diagnostic Report:

SUMMARY INFORMATION
Perch: 2.8.34, PHP: 7.1.5, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_blog (4.6), perch_events (1.9.2), perch_forms (1.8.2)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_events', 'perch_forms', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/sites/c/carelinelifestyles.co.uk/public_html/perch
PERCH_CORE: /var/sites/c/carelinelifestyles.co.uk/public_html/perch/core
PERCH_RESFILEPATH: /var/sites/c/carelinelifestyles.co.uk/public_html/perch/resources
Image manipulation: GD
PHP limits: Max upload 100M, Max POST 100M, Memory: 128M, Total max file upload: 100M
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
Resource folder writeable: Yes
DOCUMENT_ROOT: /var/sites/c/carelinelifestyles.co.uk/public_html
HTTP_HOST: carelinelifestyles.co.uk
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php

It looks like it could be the same issue here. Has there been a fix for this?

Philip Gwynne

Philip Gwynne 1 points

  • 3 years ago
Simon Clay

Simon Clay 127 points

I had this issue too, dropping back to PHP 7.0 or 5.6 solved it for me.

Perhaps your previous hosting was on an earlier version too?

I raised the issue in the forum, but wasn’t able to discover the difference between the two PHP versions that caused the issue. https://forum.grabaperch.com/forum/11-21-2016-problem-with-perch-form-with-uploads

Thanks Simon! I'm going to give that a go and report back, but dropping back down to 5.6 isn't a permanent solution security-wise as you know.

Do you know if this particular problem is solved in Perch 3? I may need to recommend that my client upgrades now.

Just to confirm your solution has fixed it Simon, thanks!

I'd appreciate it if anyone can confirm whether Perch 3 with Perch Form file uploads is working fine with PHP 7.0/7.1?

Simon Clay

Simon Clay 127 points

That's great Philip. Yes, I can confirm it works as it should in Perch 3

Perfect, thanks Simon – time to upgrade then!