public function upload()
 {
     // активное правило загрузки для файла
     $rules_name = joosRequest::post('rules_name');
     joosUpload::init($rules_name);
     $upload_result = array();
     $check = joosUpload::check();
     if ($check === true) {
         $upload_result = joosUpload::actions_before() + $upload_result;
         $upload_result = joosUpload::easy_upload(joosUpload::get_input_name(), joosUpload::get_upload_location()) + $upload_result;
         $upload_result = joosUpload::actions_after($upload_result) + $upload_result;
         // удаляем физически файл если проверки не прошли в пользователю выдаём ошибку
         if ($upload_result['success'] !== true) {
             joosFile::delete($upload_result['file_base_location']);
         }
     } else {
         $upload_result = $check;
     }
     // подчищаем секретные данные
     unset($upload_result['file_base_location']);
     return $upload_result;
 }
示例#2
0
<form id="fileupload" action="<?php 
echo joosUpload::get_upload_url();
?>
" method="POST" enctype="multipart/form-data" multiple>
    <input id="<?php 
echo joosUpload::get_input_name();
?>
" type="file" name="<?php 
echo joosUpload::get_input_name();
?>
" class="<?php 
echo joosUpload::get_class();
?>
" multiple="">
    <input type="hidden" name="rules_name" value="<?php 
echo joosUpload::get_input_name();
?>
" />
</form>

<script>
    $(function () {
        $('#fileupload').fileupload({
            dataType: 'json',
            autoUpload: true,
            acceptFileTypes: <?php 
echo joosUpload::get_accept_file_types();
?>
,
            url: '<?php 
echo joosUpload::get_upload_url();