Web based family history software

file Question Error in adding media type

  • kdmiller45
  • kdmiller45's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 3 weeks ago #116636 by kdmiller45
Error in adding media type was created by kdmiller45
I am trying to add a .pdf as a media type and get the following error when I try to save it

SyntaxError: Unexpected token '<', "
Using version Website 2.2.6

Please Log in or Create an account to join the conversation.

  • bertkoor
  • bertkoor's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
More
1 month 3 weeks ago - 1 month 3 weeks ago #116637 by bertkoor
Replied by bertkoor on topic Error in adding media type
I'm not sure what you have done exactly. Is there a stacktrace with that error message? Have you changed some code? Can you share a screenprint?

I don't think you've done the right thing. In webtrees the media type describes the type of content, not the file extention. For example the media type "picture" can be used with file extensions .png, .jpg. .bmp, etc etc, including .pdf

The .pdf file extension is already supported as a "mime type".
See github.com/fisharebest/webtrees/blob/7ed...fbb/app/Mime.php#L55

When adding a .pdf as a media object, I'd suggest "document" or "electronic" as the media type. The values are defined here:
github.com/fisharebest/webtrees/blob/7ed...rceMediaType.php#L80

stamboom.BertKoor.nl runs on webtrees v2.2.6
Last edit: 1 month 3 weeks ago by bertkoor.

Please Log in or Create an account to join the conversation.

  • hermann
  • hermann's Avatar
  • Away
  • Elite Member
  • Elite Member
More
1 month 3 weeks ago #116643 by hermann
Replied by hermann on topic Error in adding media type
The reason for that error message is that webtrees delivers JSON when html is expected. But the reason behind that is not clear. 

Hermann
Designer of the custom module "Extended Family"

webtrees 2.2.6 (100 custom modules installed, PHP 8.4.10, MariaDB 10.6) @ ahnen.hartenthaler.eu

Please Log in or Create an account to join the conversation.

  • bertkoor
  • bertkoor's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
More
1 month 3 weeks ago #116644 by bertkoor
Replied by bertkoor on topic Error in adding media type
Good thinking, Hermann!
Here's a short guide to analyse with your web browser what has happened.
webtrees.net/faq/xhr/
Although this might not have been an XHR request, the method to see request & response details is similar.

It could be that the .pdf was too large.
webtrees.net/faq/file-upload/

stamboom.BertKoor.nl runs on webtrees v2.2.6

Please Log in or Create an account to join the conversation.

  • thomas52
  • thomas52's Avatar
  • Offline
  • Premium Member
  • Premium Member
  • Western North Carolina
More
4 weeks 2 days ago #116824 by thomas52
Replied by thomas52 on topic Error in adding media type
I get same with a .jpg ... (possibly Cloudflare error?)

Research is what I’m doing when I don’t know what I’m doing – Wernher von Braun

Please Log in or Create an account to join the conversation.

  • hermann
  • hermann's Avatar
  • Away
  • Elite Member
  • Elite Member
More
4 weeks 1 day ago #116829 by hermann
Replied by hermann on topic Error in adding media type
No, that is not related to Cloudflare, the reason is in webtrees. Please, deactivate your custom modules as a first step. For example rename the folder modules_v4 to modules_v9, then test again.

Hermann
Designer of the custom module "Extended Family"

webtrees 2.2.6 (100 custom modules installed, PHP 8.4.10, MariaDB 10.6) @ ahnen.hartenthaler.eu

Please Log in or Create an account to join the conversation.

  • thomas52
  • thomas52's Avatar
  • Offline
  • Premium Member
  • Premium Member
  • Western North Carolina
More
4 weeks 1 day ago #116831 by thomas52
Replied by thomas52 on topic Error in adding media type
After renaming Models_v4 per your instructions, I still get the same error message: SyntaxError: Unexpected token '<', "

Research is what I’m doing when I don’t know what I’m doing – Wernher von Braun

Please Log in or Create an account to join the conversation.

  • bertkoor
  • bertkoor's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
More
4 weeks 1 day ago #116833 by bertkoor
Replied by bertkoor on topic Error in adding media type
Well, I tested uploading some random image to your site, and that worked. So it's either something in this specific image, or it's the network route.

You can use the webtrees demo site (login with 'editor' - 'editor') to test uploading there. Or I can test it with your specific image on your site if you send it to me. Maybe I spot something you missed...

stamboom.BertKoor.nl runs on webtrees v2.2.6

Please Log in or Create an account to join the conversation.

  • thomas52
  • thomas52's Avatar
  • Offline
  • Premium Member
  • Premium Member
  • Western North Carolina
More
4 weeks 11 hours ago #116836 by thomas52
Replied by thomas52 on topic Error in adding media type
I cancelled CloudFlare, and everything is back to normal. Now I need to deal with the bots.

Research is what I’m doing when I don’t know what I’m doing – Wernher von Braun

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum