/** * Set the attachement. * * @param string $path */ public function attach($file) { if (File::exists($file)) { $filename = explode('/', $file)[count(explode('/', $file)) - 1]; $mime = mime_content_type($file); $attachment = new \Sendgrid\Attachment(); $attachment->setContent(File::get($file)); $attachment->setType($mime); $attachment->setFilename($filename); $attachment->setDisposition('attachment'); $attachment->setContentId($filename); $this->mail->addAttachment($attachment); } return $this; }
public function testManager23() { $configs = ['prefix' => '', 'exts' => ['jpg', 'jpeg', 'png', 'gif'], 'weight' => 3000000, 'path' => 'tests/cache/', 'size' => ['square' => ['resize' => 'max', 'crop' => true, 'width' => 200, 'height' => 200]]]; $path = __DIR__ . '/dummy/dummy.jpg'; $dummies = ['name' => $path, 'type' => mime_content_type($path), 'tmp_name' => $path, 'error' => 0, 'size' => File::size($path)]; $m = new Manager($configs); $m->manage($dummies, function () { return mt_rand(1000, 100000) . '.jpg'; }); $this->assertTrue($m->success); }
public function testCheckGlob() { $this->assertEquals(count(File::glob(__DIR__ . '/dummy/*')), 1); }
/** * Handle all DOCUMENTS file formats. * * @param string $fileInfo uploaded file information the same as $_FILE['input name'] + pathinfo['file name'] * @param string $filename filename to save the new file */ private function handleDocument($fileInfo, $filename) { self::directorize($this->path); $newPath = $this->prefix . $this->path . $filename; File::copy($fileInfo['tmp_name'], $newPath); }