fixed file upload for files mod

This commit is contained in:
Ulf Gebhardt 2014-05-20 00:50:06 +02:00
parent 2fd6e789ca
commit 203684e4aa
3 changed files with 28 additions and 4 deletions

View File

@ -29,5 +29,30 @@ function register_controlls(){
}
});
});
$('#datei').change(function(){
var file = this.files[0];
var name = file.name;
var size = file.size;
var type = file.type;
//Your validation
});
$('#btn_upload').click(function(){
var formData = new FormData($('form')[0]);
$.ajax({
url: SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_files&action=upload&cat='+$(this).attr('cat'), //Server script to process data
type: 'POST',
//Ajax events
success: function(){alert('ok');},
error: function(){alert('fail');},
// Form data
data: formData,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
});
}

View File

@ -25,7 +25,6 @@ class saimod_sys_files extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_files(){
$result = array('tabopts' => '', 'tabs' => '');
$file_folders = \SYSTEM\FILES\files::get();
//$i = 0;
$first = true;
foreach($file_folders as $name=>$folder){
$result['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_files/saimod_sys_files_tabopt.tpl'),array('name' => $name, 'active' => $first ? 'active' : ''));
@ -41,7 +40,7 @@ class saimod_sys_files extends \SYSTEM\SAI\SaiModule {
$i = 0;
foreach($cat as $file){
$result .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_files/saimod_sys_files_tableentry.tpl'), array('i' => $i++, 'cat' => $name, 'name' => $file, 'extension' => substr($file,-3,3), 'url' => 'api.php?call=files&cat='.$name.'&id='.$file));}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_files/saimod_sys_files_tabfull.tpl'), array('content' => $result));}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_files/saimod_sys_files_tabfull.tpl'), array('cat' => $name, 'content' => $result));}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_files">Files</a></li>';}
public static function right_public(){return false;}

View File

@ -8,9 +8,9 @@
${content}
<tr>
<br>
<th><input type="file" name="datei"></th>
<th><form enctype="multipart/form-data"><input type="file" name="datei"></th>
<th></th>
<th></th>
<th><input type="submit" class="btn" value="Upload"></th>
<th><input type="submit" class="btn" value="Upload" id="btn_upload" cat="${cat}"></form></th>
</tr>
</table>