首先我为我的英语道歉..。
我的音乐上传有问题。我发现,感谢Symfony博士,如何上传文件和我设置我的图片上传成功。然而,我发现了我的音乐上传,我在控制器中的转储向我指出了一个错误,告诉我我的档案超过200万的问题,但是在我的文件php.ini中,upload_max_filesize被定义为256米。我上传音乐的代码和图片是一样的。
我的守则:
namespace App\Form;
use App\Entity\Artist;
use App\Entity\Category;
use App\Entity\Music;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\FileType;
class MusicType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title')
->add('description')
->add('picture', FileType::class, [
'mapped' => false,
'required' => false,
'constraints' => [
new File([
'maxSize' => '8M',
'mimeTypes' => [
'image/jpeg',
'image/png',
'image/webp'
]
])
],
'attr' => [
'accept'=>'.jpg, .jpeg, .png, .gif'
]
])
->add('music', FileType::class, [
'mapped' => false,
'constraints' => [
new File([
'maxSize' => '256M',
'mimeTypes' => [
'application/octet-stream',
'audio/mpeg',
'audio/mp3'
]
])
]
])我一直在寻找解决方案,但是所有的结果都让我回到了https://symfony.com/doc/current/reference/constraints/File.html#maxsize
如果你有想法,我很感兴趣。
发布于 2020-08-15 21:04:05
首先,您需要检查post_max_size中的php.ini。
upload_max_filesize是任何单个文件的限制。post_max_size是请求的整个主体的限制,可以包含多个文件。
确保post_max_size >= upload_max_size
见以前关于这个问题的答案。
https://stackoverflow.com/questions/63429508
复制相似问题