kohana 3上传图像而不使用任何模块? [英] kohana 3 uploading image without using any modules?

查看:136
本文介绍了kohana 3上传图像而不使用任何模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有一个在kohana 3中上传图像的例子,最终没有使用任何模块?

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

我使用 https://github.com/kohana/image/tree/3.1%2Fmaster 但我的错误是:致命错误:未捕获的Kohana_Exception [0] :已安装的GD不支持图像

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

有没有简单快捷的方法在基于kohana 3的网站上传文件?

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

谢谢!

推荐答案

Kohana API 应该有所帮助。

基本步骤是:


  1. 创建验证对象( $ array =验证::工厂($ _ FILES);

  2. 定义规则( $ array-> rule('file','Upload :: not_empty') - > rule('file','Upload :: type',array(array('jpg','png',' gif')));

  3. 检查文件( if($ array-> check() )

  4. 并保存( $ filepath = Upload :: save($ _ FILES ['file'],'uploaded_file', 'upload_dir');

  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');)

这篇关于kohana 3上传图像而不使用任何模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆