<?php

if (!empty($_POST['name']))
{
	$name = check($_POST['name']);
	$name = substr($name, 0, 100);
	if (empty($name)) {go(URL.'/doc/?id='.$user_id);}

	$dir = HOME.'/files/doc/'.$user_id;
	if (!is_dir($dir))
	{
		mkdir(HOME.'/files/doc/'.$user_id,0777);
		mkdir(HOME.'/files/doc/'.$user_id.'/icons',0777);
		mkdir(HOME.'/files/doc/'.$user_id.'/mini',0777);
		mkdir(HOME.'/files/doc/'.$user_id.'/preview',0777);
	}

	if (mysql_query("INSERT INTO `doc_papka` SET
	`user_id` = '".$user_id."',
	`name` = '".$name."',
	`uptime` = '".time()."',
	`time` = '".time()."'
	") == true)
	{
//		go(URL.'/doc/?id='.$user_id);
	}
}


?>
<script type="text/javascript">
$(function(){
	$('#form').on('submit', function(e){
	$('#form_content').html('');
	Page.Loading('start');
    e.preventDefault();
    var $that = $(this),
        formData = new FormData($that.get(0));
    $.ajax({
      url: $that.attr('action'),
      type: $that.attr('method'),
      contentType: false,
      processData: false,
      data: formData,
      success: function(response){
        if(response){
 			Page.Go($that.attr('action'));
       }
     }
    });
  });
});
</script>