From 8b23ebc05eba911e0c885e38b4f05d2e42e6be04 Mon Sep 17 00:00:00 2001 From: Juuso Lapinlampi Date: Wed, 25 May 2016 04:02:56 +0000 Subject: upload.php: Clarify what Exception $code 500 is Add comments explaining how the number 500 after Exception means HTTP status code "500 Internal Server Error". This may not be so obvious to the reader without consulting the PHP manual. Compliments commit 4606553f38909b483bc06674f9558ede1a9ff1f6. Reviewed-by: Eliot Whalan --- static/upload.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'static/upload.php') diff --git a/static/upload.php b/static/upload.php index b8fb46a..8b0646c 100644 --- a/static/upload.php +++ b/static/upload.php @@ -69,7 +69,8 @@ function generate_name($file) do { // Iterate until we reach the maximum number of retries if ($tries-- === 0) { - throw new Exception('Gave up trying to find an unused name', 500); + throw new Exception('Gave up trying to find an unused name', + 500); // HTTP status code "500 Internal Server Error" } $chars = range('a', 'z'); @@ -138,12 +139,14 @@ function upload_file($file) // Attempt to move it to the static directory if (!move_uploaded_file($file->tempfile, $uploadFile)) { - throw new Exception('Failed to move file to destination', 500); + throw new Exception('Failed to move file to destination', + 500); // HTTP status code "500 Internal Server Error" } // Need to change permissions for the new file to make it world readable if (!chmod($uploadFile, 0644)) { - throw new Exception('Failed to change file permissions', 500); + throw new Exception('Failed to change file permissions', + 500); // HTTP status code "500 Internal Server Error" } // Add it to the database -- cgit v1.2.3