<?php class Controller_Image extends Controller { public function action_index() { $config = array( 'path' => DOCROOT.DS.'files', 'randomize' => true, 'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'), ); Upload::process($config); if(Upload::is_valid()) { Upload::save(); } return Response::forge(View::forge('image/index')); } public function action_404() { return Response::forge(ViewModel::forge('welcome/404'), 404); } }
<?php echo Form::open(array('enctype' => 'multipart/form-data')); echo Form::file('filename'); echo Form::submit('submit'); echo Form::close(); ?>
<html> <head> <title>Upload test</title> <body> <?php foreach($errors as $error) { foreach($error as $message) { echo $message['message']; } } echo Form::open(array('enctype' => 'multipart/form-data')); echo Form::file('filename'); echo Form::submit('submit'); echo Form::close(); ?> </body> </html>
<?php class Controller_Image extends Controller { public function action_index() { $config = array( 'path' => '/var/www/pixelforger.com/web/thinkmeme/public/uploads', 'randomize' => true, 'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'), ); Upload::process($config); if(Upload::is_valid()) { Upload::save(); } $data = array(); $data['errors'] = ''; $ii = 0; foreach(Upload::get_errors() as $file) { $data['errors'][$ii] = $file['errors']; ++$ii; } return Response::forge(View::forge('image/index', $data)); } public function action_404() { return Response::forge(ViewModel::forge('welcome/404'), 404); } } ?>
It looks like you're new here. If you want to get involved, click one of these buttons!