Skip to content

Instantly share code, notes, and snippets.

@henriqueboaventura
Created June 18, 2012 19:03
Show Gist options
  • Save henriqueboaventura/2950100 to your computer and use it in GitHub Desktop.
Save henriqueboaventura/2950100 to your computer and use it in GitHub Desktop.
Kohana file upload validation
<?php
$file = Validation::factory($_FILES);
$file->rules(
'curriculo',
array(
array(array('Upload', 'valid')),
array(array('Upload', 'not_empty')),
array('Upload::type', array(':value', array('jpg', 'png', 'gif')))
)
);
if ($file->check()){
$filename = explode('.', $_FILES['curriculo']['name']);
Upload::save($_FILES['curriculo'],URL::title($filename[0],'-',true) . '.'. strtolower($filename[1]),UPLOAD_PATH . 'curriculos/', 0777);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment