(edit)
A files field returns an “Error. Files not uploaded” when uploading .mp3, not when uploading .wav or anything else.
This is localhost.
What can cause this?
(edit)
A files field returns an “Error. Files not uploaded” when uploading .mp3, not when uploading .wav or anything else.
This is localhost.
What can cause this?
Could you post your files field blueprint definition, and if you have assigned an upload template, that as well, please?
Is there any more information about the error in your browser console?
And what about file size of the files you’ve been trying to upload?
I ran many differently sized mp3 files through it, and it seems to be a size related error. Although files of only 9MB are returning an error.
This is then more than probably PHP config related.
Thank you.
The default is 2mb PHP limit i think. This can be increased in PHP ini or sometimes through your hosts control panel.
Funnily enough, although increasing the ul size fixes it, the error displayed with mp3 files was not about exceeding file size, as it was for other types of files, but simply “Error. Files not uploaded”.
This less specific error seems to be thrown in Api.php#747ff.
if (empty($files) === true) {
$postMaxSize = Str::toBytes(ini_get('post_max_size'));
$uploadMaxFileSize = Str::toBytes(ini_get('upload_max_filesize'));
if ($postMaxSize < $uploadMaxFileSize) {
throw new Exception(t('upload.error.iniPostSize'));
} else {
throw new Exception(t('upload.error.noFiles'));
}
}
I guess setting mime types might help. MP3 files are not a common one people upload, so might have been missed out by the defaults of your webhost.
I normally put this in .htacess
which covers most file types.
# ----------------------------------------------------------------------
# | Media types |
# ----------------------------------------------------------------------
# Serve resources with the proper media types (f.k.a. MIME types).
#
# https://www.iana.org/assignments/media-types/media-types.xhtml
# https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype
<IfModule mod_mime.c>
# Data interchange
AddType application/atom+xml atom
AddType application/json json map topojson
AddType application/ld+json jsonld
AddType application/rss+xml rss
AddType application/vnd.geo+json geojson
AddType application/xml rdf xml
# JavaScript
# Normalize to standard type.
# https://tools.ietf.org/html/rfc4329#section-7.2
AddType application/javascript js
# Manifest files
AddType application/manifest+json webmanifest
AddType application/x-web-app-manifest+json webapp
AddType text/cache-manifest appcache
# Media files
AddType audio/mp4 f4a f4b m4a
AddType audio/ogg oga ogg opus
AddType image/bmp bmp
AddType image/svg+xml svg svgz
AddType image/webp webp
AddType video/mp4 mp4 f4v f4p m4v
AddType video/ogg ogv
AddType video/webm webm
AddType video/x-flv flv
AddType audio/mpeg mp3
# Serving `.ico` image files with a different media type
# prevents Internet Explorer from displaying then as images:
# https://github.com/h5bp/html5-boilerplate/commit/37b5fec090d00f38de64b591bcddcb205aadf8ee
AddType image/x-icon cur ico
# Web fonts
AddType application/font-woff woff
AddType application/font-woff2 woff2
AddType application/vnd.ms-fontobject eot
# Browsers usually ignore the font media types and simply sniff
# the bytes to figure out the font type.
# https://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern
#
# However, Blink and WebKit based browsers will show a warning
# in the console if the following font types are served with any
# other media types.
AddType application/x-font-ttf ttc ttf
AddType font/opentype otf
# Other
AddType application/octet-stream safariextz
AddType application/x-bb-appworld bbaw
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-xpinstall xpi
AddType text/vcard vcard vcf
AddType text/vnd.rim.location.xloc xloc
AddType text/vtt vtt
AddType text/x-component htc
</IfModule>
Thank you both.