From a8d186110ea2abc6e71ef7bde24df78c978b2aa5 Mon Sep 17 00:00:00 2001 From: Marvin Herbold Date: Fri, 6 Nov 2015 10:16:22 -0700 Subject: [PATCH] Clean up redundant code. --- upload/index.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/upload/index.php b/upload/index.php index 1efa4c0..c971ce0 100644 --- a/upload/index.php +++ b/upload/index.php @@ -4,10 +4,10 @@ require( "config.php" ); +$files = array(); + if ( $_SERVER[ "REQUEST_METHOD" ] == "GET" ) { - $files = array(); - $dir = scandir( $uploads_dir ); foreach ( $dir as $file_name ) @@ -28,16 +28,9 @@ $files[] = $file; } } - - header( "Content-Type: application/json; charset=utf-8" ); - header( "Connection: close" ); - - echo json_encode( array( "files" => $files ) ); } else if ( !empty( $_FILES ) ) { - $files = array(); - foreach ( $_FILES[ "files" ][ "error" ] as $key => $error ) { if ( $error == UPLOAD_ERR_OK ) @@ -65,9 +58,9 @@ } } } - - header( "Content-Type: application/json; charset=utf-8" ); - header( "Connection: close" ); - - echo json_encode( array( "files" => $files ) ); } + +header( "Content-Type: application/json; charset=utf-8" ); +header( "Connection: close" ); + +echo json_encode( array( "files" => $files ) );