Forum

Thread tagged as: Problem

Unable to upload PDF files

Recently Perch Runway stopped allowing the upload of PDF files in my install. I click upload, select the file, the progress indication shows it uploading, but it doesn't make it to the server. This has always worked in the past.

In my debug message I do see "Form not posted or did not validate"

In my template, I have

<p><a href="<perch:content id="printmap" type="file" label="Printable map" bucket="preserve_maps" />">Download a printable preserve map (PDF)</a></p>

I have checked the file permissions on the resources folder, as well as the specified bucket and they are both set to 755.

Timothy Swan

Timothy Swan 0 points

  • 4 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

We need to see your full template and your Diagnostics Report to be able to help.

Here is the full template

<h1><perch:content id="title" type="text" label="Preserve Name" required="true" title="true" /></h1>
<perch:content id="town" type="text" label="Town name" />
<perch:content id="desc" type="textarea" label="Intro" size="xl" editor="ckeditor" html="true" />
<perch:content id="image" type="image" label="Image" width="640" output="tag" suppress="true" bucket="preserve_photos" />
<perch:content id="image" type="image" label="Image" width="100" height="100" crop="true" suppress="true" bucket="preserve_photos/thumbnails" />
<perch:content id="imagealt" type="text" label="Image description for screenreaders (not displayed)" />
<perch:content id="imagecap" type="text" label="Image caption (optional)" />
<div id="mapwrap"><div id="map" style="width: 300px; height: 350px;"></div>
<p><span class="redborder">----------</span> Preserve Boundary</p></div>
<p><a href="<perch:content id="printmap" type="file" label="Printable map" bucket="preserve_maps" />">Download a printable preserve map (PDF)</a></p>
<perch:content id="preserveinfo" type="textarea" label="Preserve information/guidelines" editor="ckeditor" html="true" />
<perch:content id="latlong" type="text" label="LatLong" suppress="true" />
<perch:content id="lat" type="text" label="Latitude - typically @ 44" />
<perch:content id="long" type="text" label="Longitude - typically @ -68" />
<perch:content id="zoom" label="Map Zoom" type="select" options="14 (Default)|14,7|7,8|8,9|9,10 (Town level)|10,11|11,12|12,13|13,15 (Street level)|15,16|16" />
<perch:content id="kml" type="file" label="KML file" suppress="true" bucket="kml" />
<perch:related id="events" collection="Events"  />
<perch:before>
<ul class="calendar plain">
</perch:before>
  <li><a href="/trips-events/<perch:content id="slug" type="slug" for="eventTitle eventDateTime" />"><perch:content id="eventDateTime" format="l, F jS Y" /></a><perch:if exists="location">, <perch:content id="location" type="text" label="Town/Location" /></perch:if>: 
    <perch:content id="eventTitle" />
  </li>
<perch:after></ul>
</perch:after>
</perch:related>
<perch:content id="slug" for="title" type="slug" suppress="true" indelible="true" />
<perch:content id="region" label="Region" type="select" suppress="true" options="None|,Southern Maine|Southern Maine,Mid-Coast|Mid-Coast,Mount Desert Island|Mount Desert Island,Downeast|Downeast" />

and the diagnostics

Perch Runway: 2.8.32, PHP: 5.6.28, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.32), assets (2.8.32), categories (2.8.32), perch_blog (5.0), collection_8 (2.8.32), collection_7 (2.8.32), perch_forms (1.8.3), perch_gallery (2.8.6), collection_2 (2.8.32), collection_6 (2.8.32), collection_1 (2.8.32), perch_backup (1.2)
App runtimes: <?php include(PERCH_PATH.'/core/apps/content/runtime.php'); // include(PERCH_PATH.'/addons/apps/perch_events/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_forms/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_blog/runtime.php'); ?>
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/mchtorg/mcht.org/perch
PERCH_CORE: /home/mchtorg/mcht.org/perch/core
PERCH_RESFILEPATH: /home/mchtorg/mcht.org/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 64M, Max POST 65M, Memory: 90M, Total max file upload: 64M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /home/mchtorg/mcht.org
HTTP_HOST: www.mcht.org
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Your template has errors, I can see that you have closed the perch:related opening tag. I would check that your template is correctly formed (I usually just remove fields till it starts working then put them back in one by one to find the culprit if I can't spot them).

Rachel Andrew said:

Your template has errors, I can see that you have closed the perch:related opening tag. I would check that your template is correctly formed (I usually just remove fields till it starts working then put them back in one by one to find the culprit if I can't spot them).

Should the perch:related tag not be closed?

And why would other file types work fine still, just not PDF files?

Drew McLellan

Drew McLellan 2638 points
Perch Support

This:

<perch:related id="events" collection="Events" />

should be this:

<perch:related id="events" collection="Events">

Got it, but that isn't related to my problem. This template has worked fine until a recent update to Perch, where it suddenly became impossible to upload PDF files specifically. It appears to upload them, but the asset doesn't appear and the file isn't in the resources directory.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Any template error can potentially cause problems with the parsing of the template, so it's important to fix.

How large is the file you're trying to upload?

It's about 350kb.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is there anything in your server error log that relates?

I don't see anything in the server log that looks like it's related to this.

Here's the (fixed) template:

<perch:content id="title" type="text" label="Preserve Name" required="true" title="true" />
<perch:content id="town" type="text" label="Town name" />
<perch:content id="desc" type="textarea" label="Intro" size="xl" editor="ckeditor" html="true" />
<perch:content id="image" type="image" label="Image" width="640" output="tag" bucket="preserve_photos" />
<perch:content id="image" type="image" label="Image" width="100" height="100" crop="true" suppress="true" bucket="preserve_photos/thumbnails" />
<perch:content id="imagealt" type="text" label="Image description for screenreaders (not displayed)" />
<perch:content id="imagecap" type="text" label="Image caption (optional)" />
<div id="mapwrap"><div id="map" style="width: 300px; height: 350px;"></div>
<p><span class="redborder">----------</span> Preserve Boundary</p></div>
<p><a href="<perch:content id="printmap" type="file" label="Printable map" bucket="preserve_maps" />">Download a printable preserve map (PDF)</a></p>
<perch:content id="preserveinfo" type="textarea" label="Preserve information/guidelines" editor="ckeditor" html="true" />
<perch:content id="latlong" type="text" label="LatLong" />
<perch:content id="lat" type="text" label="Latitude - typically @ 44" />
<perch:content id="long" type="text" label="Longitude - typically @ -68" />
<perch:content id="zoom" label="Map Zoom" type="select" options="14 (Default)|14,7|7,8|8,9|9,10 (Town level)|10,11|11,12|12,13|13,15 (Street level)|15,16|16" />
<perch:content id="kml" type="file" label="KML file" bucket="kml" />
<perch:related id="events" collection="Events">
<perch:before>
<ul class="calendar plain">
</perch:before>
  <li><a href="/trips-events/<perch:content id="slug" type="slug" for="eventTitle eventDateTime" />"><perch:content id="eventDateTime" format="l, F jS Y" /></a><perch:if exists="location">, <perch:content id="location" type="text" label="Town/Location" /></perch:if>: 
    <perch:content id="eventTitle" />
  </li>
<perch:after></ul>
</perch:after>
</perch:related>
<perch:content id="slug" for="title" type="slug" indelible="true" />
<perch:content id="region" label="Region" type="select" options="None|,Southern Maine|Southern Maine,Mid-Coast|Mid-Coast,Mount Desert Island|Mount Desert Island,Downeast|Downeast" />
<perch:content id="island" type="checkbox" label="Island" value="island" />
<perch:content id="camping" type="checkbox" label="Camping" value="camping" />
<perch:content id="trails" type="checkbox" label="Trails" value="trails" />
<perch:content id="boats" type="checkbox" label="Boat accessible" value="boats" />
<perch:content id="kayaking" type="checkbox" label="Kayaking" value="kayaking" />
<perch:content id="parking" type="checkbox" label="Parking" value="parking" />
<perch:content id="beaches" type="checkbox" label="Beaches" value="beaches" />
<perch:content id="tikibar" type="checkbox" label="Tiki Bar" value="tikibar" />
<perch:blocks>
  <perch:block type="image1" label="Image and text">
        <perch:template path="content/blocks/text_and_image.html" />
  </perch:block>
  <perch:block type="image2" label="Image">
        <perch:template path="content/blocks/content_image.html" />
  </perch:block>
  <perch:block type="image3" label="Full-size image">
        <perch:template path="content/blocks/full-width-image.html" />
  </perch:block>
  <perch:block type="text3" label="Text block">
        <perch:template path="content/blocks/text_block.html" />
  </perch:block>
  <perch:block type="text1" label="Two text block">
        <perch:template path="content/blocks/two_text_block.html" />
  </perch:block>
  <perch:block type="text2" label="Three text block">
        <perch:template path="content/blocks/three_text_block.html" />
  </perch:block>
</perch:blocks>

and the debug output:

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='37fcad2df2e13845765b8a3c975f7211' LIMIT 1
UPDATE perch2_users SET userHash='42285a32c96664462ec38ea7f4cc1c47' WHERE userID='1'
[48] SELECT p.privKey FROM perch2_user_privileges p
[63] 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
Varnish enavled!
[5] SELECT collectionID, collectionKey, collectionEditRoles FROM perch2_collections WHERE collectionInAppMenu=1 ORDER BY collectionOrder ASC
[1] SELECT * FROM perch2_collections WHERE collectionID=1 LIMIT 1
[1] SELECT ci.*, r.itemOrder, IF(r.itemLatestRev>r.itemRev,1,0) AS _has_draft FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='1' AND ci.itemRev=r.itemLatestRev AND ci.itemID=21 ORDER BY r.itemOrder ASC
[1] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='1' AND ci.itemRev=r.itemRev AND ci.itemID=21
[1] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='1' AND ci.itemRev=r.itemRev AND r.itemOrder > '1062' ORDER BY r.itemOrder LIMIT 1
[1] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='1' AND ci.itemRev=r.itemRev AND r.itemOrder < '1062' ORDER BY r.itemOrder DESC LIMIT 1
Using template: /templates/content/preserves/preserve_detail.html
Using sub-template: /templates/content/blocks/text_and_image.html
Using sub-template: /templates/content/blocks/content_image.html
Using sub-template: /templates/content/blocks/full-width-image.html
Using sub-template: /templates/content/blocks/text_block.html
Using sub-template: /templates/content/blocks/two_text_block.html
Using sub-template: /templates/content/blocks/three_text_block.html
Form not posted or did not validate
[1] SELECT itemRev, itemLatestRev FROM perch2_collection_revisions WHERE collectionID=1 AND itemID=21 LIMIT 1
[1] SELECT * FROM perch2_collections WHERE collectionKey='Events' LIMIT 1
[7] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='7' AND ci.itemRev=r.itemRev ORDER BY r.itemOrder ASC

Again, this has been working for quite some time, so it's hard to know why it would suddenly stop.

I did find these two lines in the server logs:

XX.XX.XX.XXX - - [19/Dec/2016:07:07:20 -0800] "POST /perch/core/apps/assets/upload/ HTTP/1.1" 200 435 "https://www.mcht.org/perch/core/apps/content/collections/edit/?id=1&itm=21" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0.1 Safari/602.2.14" 
XX.XX.XX.XXX - - [19/Dec/2016:07:07:21 -0800] "GET /perch/core/apps/assets/async/get-assets.php?page=1&v=2.8.32&type=doc&bucket=preserve_maps&_=1482160022116 HTTP/1.1" 200 2571 "https://www.mcht.org/perch/core/apps/content/collections/edit/?id=1&itm=21" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0.1 Safari/602.2.14" 
Drew McLellan

Drew McLellan 2638 points
Perch Support

That looks like the access log. Do you have an error log?

Yes, there are no errors related to this problem. Super weird.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm not sure I have anything further to suggest.

Thanks. I'm sure I'll figure it out eventually.

Could this be related to the use of GD Imagick on my server to process images?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Which are you using currently?

Well, I never have been able to figure this one out. Uploading PDFs on my local copy of the site is no problem, but I've been unable to upload them to the live site.

This is using the Assets button, so it's not a problem with any of my templates. I've tried GD and ImageMagick, neither works. Here is the debug output:

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='9bd51a403f3e7385154160df3c02b8e7' LIMIT 1
UPDATE perch2_users SET userHash='2cb497012662dd6fbde61ca0f5572918' WHERE userID='1'
[48] SELECT p.privKey FROM perch2_user_privileges p
[64] 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
Varnish enavled!
[5] SELECT collectionID, collectionKey, collectionEditRoles FROM perch2_collections WHERE collectionInAppMenu=1 ORDER BY collectionOrder ASC
[30] SELECT SQL_CALC_FOUND_ROWS DISTINCT r1.*, r2.resourceFile AS thumb, r2.resourceWidth AS thumbWidth, r2.resourceHeight AS thumbHeight, r2.resourceDensity AS thumbDensity FROM perch2_resources r1 LEFT OUTER JOIN perch2_resources r2 ON r2.resourceParentID=r1.resourceID AND r2.resourceKey='thumb' AND r2.resourceAWOL!=1 WHERE r1.resourceKey='orig' AND r1.resourceAWOL=0 ORDER BY r1.resourceUpdated DESC, r1.resourceID DESC LIMIT 0, 30
[387] SELECT FOUND_ROWS() AS `count`
[6] SELECT DISTINCT resourceType FROM perch2_resources WHERE resourceAWOL=0 AND resourceType !="" ORDER BY resourceType ASC
[6] SELECT DISTINCT resourceBucket FROM perch2_resources WHERE resourceAWOL=0 AND resourceType !=""
Queries: 10
Memory: 1.2586

Perch Runway is the latest version. Permissions on the buckets have been checked and re-checked.

Help!?!

Problem solved. I turned on Paranoid mode a while ago and had "define('PERCH_VERIFY_UPLOADS', true);" which apparently triggered this problem. That must mean that my filetypes.ini file rule for PDF files is wrong (I have "application/pdf".)

Thanks.