示例#1
0
 function upload_pix($filepath = "")
 {
     $ext = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION);
     if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png' || $ext == 'jpeg') {
         $image = new Imageresize();
         $image->load($_FILES["image"]["tmp_name"]);
         $image->resize(1300, 400);
         $custom_name = rand(3, 500) . "_" . time();
         $filepath = $custom_name . "." . $ext;
         $path = "../public/images/" . $filepath;
         $image->save($path);
         $image->create($filepath);
         return $filepath;
     } else {
         return 3;
     }
 }