PDF file could not be uploaded on production server

This is a new issue.

When uploading a PDF to a page on my production server, it throws an error:

When uploading to my local environment, it works fine:

This has not been a problem in the past, it only started happening recently. I updated from version 3.5 to 3.7.5 to see if that would help but itā€™s still throwing the same error.

This is the code:

<a href="<?= $page->files()->first()->url() ?>" target="_blank" title="View dine-in menu">
      <span class="A">Dine-in</span>
</a>

I am aware that in some instances youā€™re supposed to use toFile() then call the url(), however, this wasnā€™t workingā€¦ It would not link to the URL:

<?php if($file = $page->files()->first()->toFile()): ?>
<a href="<?= $file->url() ?>" target="_blank" title="View dine-in menu">
      <span class="A">Dine-in</span>
</a>
<?php endif ?>

The first snippet was working at the time of launch and still works on my local environment.

Any ideas what is causing this? Might it be a server issue?

Have you changed the version of php being used on your remote server? It might be that the PHP ini has changed and the max file size of uploads is smaller than it used to be. The default i believe is 2 megabytes.

You can usually check / set these values through your hosting control panel rather than having to so it manually.

Maybe the quota of the webspace is full?

Thanks for the replies @jimbobrjames @tojai

Update: Turns out itā€™s something to do with the PDF / one of the fonts.

When I outline the text in InDesign or Illustrator, the PDF uploads fine. However, when the PDF is exported with text that is not outlined, it throws the error ā€œThe file could not be uploadedā€.

There are only two fonts used in the PDF so I tested them individually. Strangely, the error only happens with ABC Whyte Medium.

Unsure if this is an issue with the font file or a Kirby bug? Unsure if I need to contact ABC Dinamo or whether this concerns other similar fontsā€¦

This isnā€™t ideal because the client will need to update the PDF themselves so getting them to outline the text everytime is an extra step that could cause issues in the future.

Has anyone experienced something similar before?

This sounds strange to me. A PDF file is nothing special regarding the fonts. Maybe some heuristic of some IT security solution (anti virus, firewall, web application firewall, ā€¦) is triggered due to the specific font like a false positive?

Another idea, maybe the font adds massively to the file size thus breaking some limits?

Might be the mime settings. When uploading do you use a blueprint for the pdf?

@tojai The only file blueprint I have is default.yml as follows:

title: Gallery
icon: blank

accept:
  extension: pdf, png, jpg

sections:
  info:
    type: fields
    fields:
      notes:
        label: Notes
        type: textarea

Is there anything I can do about the Mime settings? Iā€™ve never come across this before.

Also, is there any reason why the second PHP snippet with the if statement and toFile() does not work? Could this perhaps be related?

This doesā€™t make sense, because $page->files()->first() would already return a file object (or null if there are no files), so you cannot convert that to a file object again with toFile(). toFile() is a field method you would call on a files field.

Regarding the PDFs: So a standard PDF upload works and you only have this issue with particular PDFs?

@warg Agree, editable text in the PDF should not be an issue. It hasnā€™t been an issue for me in the past. I wonder if there is a way to debug this?

In terms of file size:

PDF with editable text = 21kb
PDF with outlined text = 133kb

I donā€™t think this should be an issue. The live site is parcs.com.au for reference.

Thanks @texnixe makes sense.

Regarding PDFs: It is only an issue with PDFs that have editable text (with a certain font). It seems to be fine with PDFs that have outlined text.

Still strangeā€¦?

If it helps, I could forward you both PDFs for inspection?

I have uploaded them here to a Google Drive (OL for outlined text): Parcs Menus_Test_1010 ā€“ Google Disk

Could you also check your PHP error logs and server error logs. Maybe they have some more enlightening error messages.

I tested both your files locally (Laravel Valet on a Mac) and didnā€™t have any issues uploading them.

What does your field or section definition look like?

Hi @texnixe

Where do I find the PHP or server error logs? This site is deployed with cPanel.

The blueprint for this page is as below:

title: Home
icon: circle

sections:
  intro:
    type: fields
    fields:
      tagline:
        type: text
        size: small
  menu:
    type: files
    layout: cards
    image:
      back: white