Skip to content

Commit

Permalink
unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdual committed Nov 6, 2020
1 parent 0ed4396 commit 86d795d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,13 @@ public function check()
$image_dimensions = getimagesize($this->file["tmp_name"]);
if (!$image_dimensions) {
$this->error = self::ERR_NOT_AN_IMAGE;
}
if ($this->error === null && $this->max_image_dimensions !== null) {
} else if ($this->max_image_dimensions !== null) {
for ($i = 0; $i <= 1; $i++) {
if (isset($this->max_image_dimensions[$i]) && is_numeric($this->max_image_dimensions[$i]) && $image_dimensions[$i] > $this->max_image_dimensions[$i]) {
$this->error = self::ERR_MAX_DIMENSION;
}
}
}
if ($this->error === null && $this->min_image_dimensions !== null) {
} else if ($this->min_image_dimensions !== null) {
for ($i = 0; $i <= 1; $i++) {
if (isset($this->min_image_dimensions[$i]) && is_numeric($this->min_image_dimensions[$i]) && $image_dimensions[$i] < $this->min_image_dimensions[$i]) {
$this->error = self::ERR_MIN_DIMENSION;
Expand Down Expand Up @@ -461,7 +459,7 @@ public function upload($copy_file = false)
@mkdir($upload_dir, 0777, true);
}
$filepath = $this->get_path();
if ($this->override === false && $this->encrypt_name === false && file_exists($filepath)) {
if ($this->override === false && file_exists($filepath)) {
$number = 2;
$filename = pathinfo($filepath, PATHINFO_FILENAME);
do {
Expand Down Expand Up @@ -580,7 +578,8 @@ public static function create_temp_file($source, $mime_map = [])
if (isset($mime_map[$mime])) {
$ext = $mime_map[$mime];
} else {
$ext = array_pop(explode("/", $mime));
$arr = explode("/", $mime);
$ext = end($arr);
}

register_shutdown_function(function() use ($temp) {
Expand Down
1 change: 1 addition & 0 deletions tests/FileNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function testName5()
$upload->encrypt_name();

$this->assertNotEquals($upload->get_name(), "foo.json");
$this->assertEquals($upload->encrypt_name, false); // Because it's setting to 'true' once
}

public function testName6()
Expand Down

0 comments on commit 86d795d

Please sign in to comment.