Closed crism closed 8 years ago
In the server error log at the time of upload is this message: PHP Warning: POST Content-Length of 60730159 bytes exceeds the limit of 8388608 bytes in Unknown on line 0, referer: http://.../scalar/dummy-book/upload
.
Hi @crism,
Thanks for pointing this out! I'm able to duplicate the issue on my end. What's occurring is that the PHP error at the top is HTML which causes jQuery to not be able to parse the return as JSON. I should be able to trap inside a try/catch and place into an error field in the JSON, as you suggest.
Nb, uploading occurs here: https://github.com/anvc/scalar/blob/master/system/application/libraries/File_Upload.php
I'll add this to my list of things to correct.
Thanks, @craigdietrich.
Hi @crism, this is now corrected in https://github.com/anvc/scalar/commit/0f75b1bcc0b13b69be8840cfcea8d84b64098377
PHP was correctly throwing errors when the file was too big for upload_max_filesize, but not when the file was too big for post_max_size.
Thanks for logging this bug!
Great, @craigdietrich—thanks!
If a user attempts to upload a file for a book, and that file is larger than the local PHP configuration allows, the user receives a JavaScript alert with the confusing message: “There was an error saving the file: SyntaxError: Unexpected token <”
This appears to trace to
system/application/views/arbors/html/common.js
, in whichvalidate_upload_form_file_return()
parses the server’s response as JSON. However, since PHP threw an error, the response is HTML; the resulting parse error is presented to the user.I’m not sure exactly who handles the
upload
route (CI_Upload
?), but it should probably have an option to respond in JSON or HTML, or atry
/catch
block to intercept errors (and turn them into JSON), whichever’s appropriate.