I have a field set for an image upload to a folder.
PHP-General Options is setup correctly with a writeable upload folder, etc.
The field has it’s image tag set to upload and the view tag to image
When I select the file, the form edit page immediately displays ‘File not found’ and 'SyntaxError: Unexpected token < in JSON at position 0’Needless to say, the file DOES exist - I’ve just selected it!Any ideas what I’m doing wrong?
What is your upload folder name in the project? Is it upload? If so, then change it to another name, for example: uploads, re-generate ALL the script files, and try again.Similar to: https://discourse.hkvstore.com/t/how-to-resolve-syntaxerror-unexpected-token-in-json-during-import/3510/1
Upload folder is set as “posters/”
Deleted EVERYTHING and regenerated with a Composer update and I still get the same error…
When there is a PHP error, the data returned from server will be the PHP error message, not the expected JSON, so the JavaScript cannot parse it and hence the syntax error. When this error happens, you may try:
- Click Tools → Advanced Settings, enable Debug, generate the config.php again so that the PHP error message will contain the full error message,
- Press F12 in Chrome, go to the Netowork panel, find the HTTP request with error, check the HTTP response from server, (see View a response body), you should be able to see the PHP error there.
Thanks. The problem was nothing to do with upload and was an INCLUDE file in Global Code. I hadn’t realised that the path to global code had changed in v2021.
It would be great if this could be mentioned in “Migrating to v2021” in the help file!