Blame view

sources/apps/bookmarks/ajax/import.php 796 Bytes
d1bafeea1   Kload   [fix] Upgrade to ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  <?php
  
  OCP\App::checkAppEnabled('bookmarks');
  
  
  $l = new OC_l10n('bookmarks');
  if(empty($_FILES)) {
  	 OCP\Util::writeLog('bookmarks',"No file provided for import", \OCP\Util::WARN);
  	$error[]= $l->t('No file provided for import');
  }elseif (isset($_FILES['bm_import'])) {
  	$file = $_FILES['bm_import']['tmp_name'];
  	if($_FILES['bm_import']['type'] =='text/html')	{
  		$error = OC_Bookmarks_Bookmarks::importFile($file);
  		if( empty($errors) ) {
  			OCP\JSON::success();
  			//force charset as not set by OC_JSON
  			header('Content-Type: application/json; charset=utf-8');
  			exit();
  		}
  	} else {
  		$error[]= $l->t('Unsupported file type for import');
  	}
  }
  
  OC_JSON::error(array('data'=>$error));
  //force charset as not set by OC_JSON
  header('Content-Type: application/json; charset=utf-8');
  exit();