Question about uploading mp3 sound

Hello,

I’ve bought a Kirby theme ZOOn which is nice. But unlike it’s said I can’t directly upload a mp3 file to have a sound on a page.

Do you know where I can dig a little further to try to fix that ?

Thanks

Uploading .mp3 files should work out of the box, unless there is something preventing it.

Likely reasons:

  • The file is too large for your PHP settings max_upload_size and related settings
  • The file size or file type are not allowed by the file blueprint assigned to the field/section where you want to upload to

Thanks !
You’re right
It works with a very small mp3
Do you think I can change the php settings for upload size ?
I had a look into the audio.php and I can’t see any limitation for uploading…

Usually, yes. Are you testing locally or on a remote server? If on a remote server, check the docs of your hosting provider. The following settings are relevant:

max_execution_time
memory_limit
post_max_size
upload_max_filesize

If you have access to the php.ini file, you can change the settings there.

Thanks very much for answering.
I’m testing locally right now and can’t find the “php.ini” file

There’s an upload file but I don’t know how fiddle it

> 
> <?php
> 
> use Kirby\Cms\Api;
> use Kirby\Cms\File;
> use Kirby\Exception\Exception;
> use Kirby\Exception\InvalidArgumentException;
> 
> return [
> 	'props' => [
> 		/**
> 		 * Sets the upload options for linked files (since 3.2.0)
> 		 */
> 		'uploads' => function ($uploads = []) {
> 			if ($uploads === false) {
> 				return false;
> 			}
> 
> 			if (is_string($uploads) === true) {
> 				$uploads = ['template' => $uploads];
> 			}
> 
> 			if (is_array($uploads) === false) {
> 				$uploads = [];
> 			}
> 
> 			$uploads['accept']  = '*';
> 
> 			if ($preview = $this->image) {
> 				$uploads['preview'] = $preview;
> 			}
> 
> 			if ($template = $uploads['template'] ?? null) {
> 				// get parent object for upload target
> 				$parent = $this->uploadParent($uploads['parent'] ?? null);
> 
> 				if ($parent === null) {
> 					throw new InvalidArgumentException('"' . $uploads['parent'] . '" could not be resolved as a valid parent for the upload');
> 				}
> 
> 				$file = new File([
> 					'filename' => 'tmp',
> 					'parent'   => $parent,
> 					'template' => $template
> 				]);
> 
> 				$uploads['accept'] = $file->blueprint()->acceptAttribute();
> 			}
> 
> 			return $uploads;
> 		},
> 	],
> 	'methods' => [
> 		'upload' => function (Api $api, $params, Closure $map) {
> 			if ($params === false) {
> 				throw new Exception('Uploads are disabled for this field');
> 			}
> 
> 			$parent = $this->uploadParent($params['parent'] ?? null);
> 
> 			return $api->upload(function ($source, $filename) use ($parent, $params, $map) {
> 				$props = [
> 					'source'   => $source,
> 					'template' => $params['template'] ?? null,
> 					'filename' => $filename,
> 				];
> 
> 				// move the source file from the temp dir
> 				$file = $parent->createFile($props, true);
> 
> 				if ($file instanceof File === false) {
> 					throw new Exception('The file could not be uploaded');
> 				}
> 
> 				return $map($file, $parent);
> 			});
> 		},
> 		'uploadParent' => function (string|null $parentQuery = null) {
> 			$parent = $this->model();
> 
> 			if ($parentQuery) {
> 				$parent = $parent->query($parentQuery);
> 			}
> 
> 			if ($parent instanceof File) {
> 				$parent = $parent->parent();
> 			}
> 
> 			return $parent;
> 		}
> 	]
> ];

That is kirby core, don’t touch it.

That file is not part of your kirby project. Maybe contact your provider if you cannot find any settings in cPanel or whatever admin the hosting is using, where to change this.

1 Like