I’m trying to upload a css file. I’ve successfully uploaded them before but for some reason, I’m getting a popup error that says “No file uploaded or invalid file type!”
OJS relies on the system’s file type determination tools, and sometimes these guess wrong. OJS is looking for the system to report either a text/css or text/plain MIME type, and I suspect those comments were causing it to detect something else (perhaps C code). If you’re content to continue without those comments in place, then I’d suggest doing that.
Regards,
Alec Smecher
Public Knowledge Project Team
OJS uses file type identification tools built into your server, and I suspect these are misfiring. Try running file -m /path/to/myfile.css to see what it detects (if you’re on a *NIX-like system).
Regards,
Alec Smecher
Public Knowledge Project Team
You’ll need to run this on the OJS machine for the result to be useful. Note that OJS may not use exactly the same toolset as the file tool – depending on your PHP configuration – but this will be a good starting point for further debugging.
Regards,
Alec Smecher
Public Knowledge Project Team
Since “mime_content_type” function in “PKPString.inc.php” uses PHP’s “finfo” function first if available (should be available in PHP >=5.3.0), falling back to the deprecated PHP function “mime_content_type” (confusingly of the same name) and then falling back to command line tool “file”. I’d suggest to check what “finfo” does with the file using the same magic database that is configured in config.inc.php at line 230 (by default commented out though).
You could just open PHP interactive shell with php -a and then run a test with entered line by line (or create a script and just run that):
The PHP function mime_content_type is not actually deprecated. It was incorrectly marked deprecated in a couple of versions of the PHP documentation, however.
OJS 3.x inherited a kludge I put into OJS 2.x which can help to disambiguate faulty MIME detection. See:
The general idea is: if we know what file extension we were given, and MIME detection returned an ambiguous result which doesn’t match the extension, change the MIME type to match the extension.
This really ought to be exposed in the UI and database, but it is stuck in the code for now.
I am having exactly the same problem, but not regarding comments (PS: read ps, problems too after all), it is regarding the “float” property: if I used float in my css, when I try to upload a stylesheet OJS says it is an invalid file type, but acpets it without a “float:right;” line. With this block it does not acept:
I found it by try and error. Using the latedst OJS + Fedora + Negingx + Latest PHP + MariaDB
I share this if usefull for someone googlin in the future and for bug hunting.
PS: after all, comments give trouble too like the main question in this topic. Had to delete a comment so OJS could acept my css. If usefull for bug hunting, I post my original CSS file next (had to delet comments and the “float:right;” line for OJS to acept it) note: changed file names and directories by xxx: