aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Poche.class.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2014-02-28 20:36:32 +0100
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2014-02-28 20:36:32 +0100
commit31a10069a52c2fd2aca3a835a7bdc1accae197f5 (patch)
treedc29926cfb6fbd582c046b8909b7f5094a17c263 /inc/poche/Poche.class.php
parent4c14936353253ab521d6b64d0b9eafcb5e490cec (diff)
downloadwallabag-31a10069a52c2fd2aca3a835a7bdc1accae197f5.tar.gz
wallabag-31a10069a52c2fd2aca3a835a7bdc1accae197f5.tar.zst
wallabag-31a10069a52c2fd2aca3a835a7bdc1accae197f5.zip
[add] upload form for import
Diffstat (limited to 'inc/poche/Poche.class.php')
-rwxr-xr-xinc/poche/Poche.class.php24
1 files changed, 17 insertions, 7 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 49651c52..026b0b4e 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -1068,13 +1068,7 @@ class Poche
1068 Tools::redirect(); 1068 Tools::redirect();
1069 } 1069 }
1070 1070
1071 $targetDefinition = 'IMPORT_' . strtoupper($from) . '_FILE'; 1071 $targetFile = CACHE . '/' . constant(strtoupper($from) . '_FILE');
1072 $targetFile = constant($targetDefinition);
1073
1074 if (! defined($targetDefinition)) {
1075 $this->messages->add('e', _('Incomplete inc/poche/define.inc.php file, please define "' . $targetDefinition . '".'));
1076 Tools::redirect();
1077 }
1078 1072
1079 if (! file_exists($targetFile)) { 1073 if (! file_exists($targetFile)) {
1080 $this->messages->add('e', _('Could not find required "' . $targetFile . '" import file.')); 1074 $this->messages->add('e', _('Could not find required "' . $targetFile . '" import file.'));
@@ -1084,6 +1078,22 @@ class Poche
1084 $this->$providers[$from]($targetFile); 1078 $this->$providers[$from]($targetFile);
1085 } 1079 }
1086 1080
1081 public function uploadFile() {
1082 if(isset($_FILES['file']))
1083 {
1084 $dir = CACHE . '/';
1085 $file = basename($_FILES['file']['name']);
1086 if(move_uploaded_file($_FILES['file']['tmp_name'], $dir . $file)) {
1087 $this->messages->add('s', _('File uploaded. You can now execute import.'));
1088 }
1089 else {
1090 $this->messages->add('e', _('Error while importing file. Do you have access to upload it?'));
1091 }
1092 }
1093
1094 Tools::redirect('?view=config');
1095 }
1096
1087 /** 1097 /**
1088 * export poche entries in json 1098 * export poche entries in json
1089 * @return json all poche entries 1099 * @return json all poche entries