Exemple #1
0
 public function testUploaderSave()
 {
     $uploader = new Uploader($this->local, $this->source);
     $uploader->addRule(new SizeRule(100000));
     $uploader->check();
     $uploader->save();
 }
 public function handleUpload()
 {
     // use ring to handle the upload
     $rules = array(new SizeRule(10000), new MimeTypeRule(array('image/jpeg')));
     try {
         $source = new UploadedFile("data");
         // note the working directory is public, where the index.php is
         $backend = new LocalBackend("upload");
         $uploader = new Uploader($backend, $source);
         $uploader->check();
         $uploader->save();
         return response()->json(array('file' => $source->getInfo()));
     } catch (ExceptionInterface $e) {
         return response()->json(array('msg' => $e->getMessage()), 400);
     }
 }