1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2024-11-29 04:24:11 +01:00
OwncloudBookmarksOfficial/ajax/import.php
2013-02-19 00:04:29 +01:00

29 lines
796 B
PHP

<?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();