From f423684b5303b4196c8c728eb06cbd6eb9aad8b1 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Sun, 2 Oct 2011 19:30:37 -0700 Subject: Merged file mime type detection from 1.7. --- mod/file/actions/file/upload.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mod/file/actions') diff --git a/mod/file/actions/file/upload.php b/mod/file/actions/file/upload.php index 88a01745d..ee2889b4c 100644 --- a/mod/file/actions/file/upload.php +++ b/mod/file/actions/file/upload.php @@ -90,10 +90,11 @@ if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) { $filestorename = elgg_strtolower(time().$_FILES['upload']['name']); } - $file->setFilename($prefix.$filestorename); - $file->setMimeType($_FILES['upload']['type']); + $mime_type = $file->detectMimeType($_FILES['upload']['tmp_name'], $_FILES['upload']['type']); + $file->setFilename($prefix . $filestorename); + $file->setMimeType($mime_type); $file->originalfilename = $_FILES['upload']['name']; - $file->simpletype = file_get_simple_type($_FILES['upload']['type']); + $file->simpletype = file_get_simple_type($mime_type); // Open the file to guarantee the directory exists $file->open("write"); -- cgit v1.2.3 From 1e4c47b736718ecb18a4367657e147e412fab06e Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 10 Oct 2011 20:15:09 -0400 Subject: Refs #3919 merged file upload failure check to master --- mod/file/actions/file/upload.php | 6 +++++- mod/file/languages/en.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'mod/file/actions') diff --git a/mod/file/actions/file/upload.php b/mod/file/actions/file/upload.php index ee2889b4c..3edc87952 100644 --- a/mod/file/actions/file/upload.php +++ b/mod/file/actions/file/upload.php @@ -19,6 +19,11 @@ if ($container_guid == 0) { elgg_make_sticky_form('file'); +// check if upload failed +if (!empty($_FILES['upload']['name']) && $_FILES['upload']['error'] != 0) { + register_error(elgg_echo('file:cannotload')); + forward(REFERER); +} // check whether this is a new file or an edit $new_file = true; @@ -29,7 +34,6 @@ if ($guid > 0) { if ($new_file) { // must have a file if a new file upload if (empty($_FILES['upload']['name'])) { - $error = elgg_echo('file:nofile'); register_error($error); forward(REFERER); diff --git a/mod/file/languages/en.php b/mod/file/languages/en.php index aa30084a9..96fbd1c48 100644 --- a/mod/file/languages/en.php +++ b/mod/file/languages/en.php @@ -100,7 +100,7 @@ $english = array( 'file:downloadfailed' => "Sorry; this file is not available at this time.", 'file:deletefailed' => "Your file could not be deleted at this time.", 'file:noaccess' => "You do not have permissions to change this file", - 'file:cannotload' => "There was an error loading the file", + 'file:cannotload' => "There was an error uploading the file", 'file:nofile' => "You must select a file", ); -- cgit v1.2.3