diff options
author | Andrew Dolgov <[email protected]> | 2016-08-19 18:14:22 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2016-08-19 18:14:22 +0300 |
commit | 1a322ff3dfb47a73f52f4076b9d73601999c573e (patch) | |
tree | 6f09c810bc29ad432ac934a7d21c8538650e6f66 /plugins/import_export/init.php | |
parent | a84fb943b4c5a030e215fa819e579ca4646cf617 (diff) |
import_export: better error message if upload failed
Diffstat (limited to 'plugins/import_export/init.php')
-rw-r--r-- | plugins/import_export/init.php | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/plugins/import_export/init.php b/plugins/import_export/init.php index 7c628909f..491216e06 100644 --- a/plugins/import_export/init.php +++ b/plugins/import_export/init.php @@ -425,34 +425,35 @@ class Import_Export extends Plugin implements IHandler { print "<div style='text-align : center'>"; if ($_FILES['export_file']['error'] != 0) { - print_error(T_sprintf("Upload failed with error code %d", - $_FILES['export_file']['error'])); - return; - } + print_error(T_sprintf("Upload failed with error code %d (%s)", + $_FILES['export_file']['error'], + get_upload_error_message($_FILES['export_file']['error']))); + } else { - $tmp_file = false; + $tmp_file = false; - if (is_uploaded_file($_FILES['export_file']['tmp_name'])) { - $tmp_file = tempnam(CACHE_DIR . '/upload', 'export'); + if (is_uploaded_file($_FILES['export_file']['tmp_name'])) { + $tmp_file = tempnam(CACHE_DIR . '/upload', 'export'); - $result = move_uploaded_file($_FILES['export_file']['tmp_name'], - $tmp_file); + $result = move_uploaded_file($_FILES['export_file']['tmp_name'], + $tmp_file); - if (!$result) { - print_error(__("Unable to move uploaded file.")); + if (!$result) { + print_error(__("Unable to move uploaded file.")); + return; + } + } else { + print_error(__('Error: please upload OPML file.')); return; } - } else { - print_error(__('Error: please upload OPML file.')); - return; - } - if (is_file($tmp_file)) { - $this->perform_data_import($tmp_file, $_SESSION['uid']); - unlink($tmp_file); - } else { - print_error(__('No file uploaded.')); - return; + if (is_file($tmp_file)) { + $this->perform_data_import($tmp_file, $_SESSION['uid']); + unlink($tmp_file); + } else { + print_error(__('No file uploaded.')); + return; + } } print "<button dojoType=\"dijit.form.Button\" |