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 ) );