dtz8044 2018-05-18 02:44
浏览 37
已采纳

Laravel图像(在商店图片上工作)

I am working on a laravel store image function. Fortunately it is working. But my problem is when I'm trying to upload atleast 20+ images. It only stores the first 20 images.

My question is, is there any settings that restricts my code to upload 20+ more files ?

Here is my code

public function storeImages($keycode, $projectsID){
    if(!empty($_FILES[$keycode]['name']) && isset($_FILES[$keycode]) && is_array($_FILES[$keycode]['name'])):
        for($i = 0; $i < count($_FILES[$keycode]['name']); $i++):
            $filename = preg_replace("/[^a-z0-9A-Z\.]/","_",$_FILES[$keycode]['name'][$i]);
            move_uploaded_file($_FILES[$keycode]['tmp_name'][$i],"uploads/projects/".$filename); //stores original size
            try{
                if(trim($filename) != ""){
                    $img = \Image::make("uploads/projects/".$filename); //opens the original sizes
                    $img->resize(200,200); // resize original
                    $img->save('uploads/projects/200x200_'.$filename); // save resize images
                    $new = array();
                    $new['id'] = \App\Helper\ModelHelper::uuid();
                    $new['project_id'] = $projectsID;
                    $new['type'] = "BEFORE";
                    $new['img_name'] = $filename;
                    DB::table("projects_photos")->insert($new);
                }
            }catch(Exception $e){

            }
        endfor;
    endif;
}
  • 写回答

2条回答 默认 最新

  • douci2516 2018-05-18 03:36
    关注

    In php.ini

    ; Maximum number of files that can be uploaded via a single request
    max_file_uploads = 20
    

    Change this and restart apache/nginx server

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 安装opengauss数据库报错
  • ¥15 【急】在线问答CNC雕刻机的电子电路与编程
  • ¥60 在mc68335芯片上移植ucos ii 的成功工程文件
  • ¥15 笔记本外接显示器正常,但是笔记本屏幕黑屏
  • ¥15 Python pandas
  • ¥15 蓝牙硬件,可以用哪几种方法控制手机点击和滑动
  • ¥15 生物医学数据分析。基础课程就v经常唱课程舅成牛逼
  • ¥15 云环境云开发云函数对接微信商户中的分账功能
  • ¥15 空间转录组CRAD遇到问题
  • ¥20 materialstudio计算氢键脚本问题