kohana 3 uploading image without using any modules

2020-08-04 09:51发布

does anybody have an example of uploading images in kohana 3 without using any modules eventually ?

i used https://github.com/kohana/image/tree/3.1%2Fmaster but my error is: Fatal error: Uncaught Kohana_Exception [ 0 ]: Installed GD does not support images

is there any easy and fast way to upload files in a kohana 3 based website?

thanks!

2条回答
兄弟一词,经得起流年.
2楼-- · 2020-08-04 10:17

Kohana API should help.

Basic steps are:

  1. Create Validation object ($array = Validation::factory($_FILES);)
  2. Define rules ($array->rule('file', 'Upload::not_empty')->rule('file', 'Upload::type', array(array('jpg', 'png', 'gif')));)
  3. Check file(s) (if ($array->check()))
  4. And save it ($filepath = Upload::save($_FILES['file'], 'uploaded_file', 'upload_dir');)
查看更多
登录 后发表回答