Skip to content

Commit

Permalink
Clean up redundant code.
Browse files Browse the repository at this point in the history
  • Loading branch information
mherbold committed Nov 6, 2015
1 parent d1349d9 commit a8d1861
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions upload/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 )
Expand Down Expand Up @@ -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 ) );

0 comments on commit a8d1861

Please sign in to comment.