dousui6488 2018-12-03 15:34 采纳率: 100%
浏览 32

在Symfony中清空上传的文件

I want to upload a csv file with a form but if the file is too big (> 200 rows) it doesn't work.

For instance, when I upload a big file and I do:

 die(var_dump($request->files->get('file')));

Here is the result:

object(Symfony\Component\HttpFoundation\File\UploadedFile)#9 (7) { ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> bool(false)
["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(12) "big_file.csv" 
["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(24) "application/octet-stream" 
["size":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(0) 
["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(1) ["pathName":"SplFileInfo":private]=> string(0) "" 
["fileName":"SplFileInfo":private]=> string(0) "" }

As you can see, the size is 0, the fileName and the pathName are empty and the mime type is wrong (it should be text/csv). And when I upload a small file (around 100 rows) it works, there is the good size, the pathName/fileName etc.

Do you know if it's a problem with PHP?

FYI, I have these settings in the PHP code:

ini_set('upload_max_filesize', '40M');
ini_set('post_max_size', '40M');
ini_set('max_input_time', 600);
ini_set('max_execution_time', 600);
ini_set('memory_limit', '256M');
set_time_limit(0);

Regards

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 yolov8边框坐标
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂