summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorJuuso Lapinlampi <wub@partyvan.eu>2016-05-25 06:02:56 +0200
committerJuuso Lapinlampi <wub@partyvan.eu>2016-05-25 06:15:42 +0200
commit8b23ebc05eba911e0c885e38b4f05d2e42e6be04 (patch)
tree7d2ecf49d5ee84150a86e0d4386cf8fa4cc10e13 /static
parentea0d6dcf36d5f1832e49bdd8c44dc9570a1eeb96 (diff)
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 <ewhal@pantsu.cat>
Diffstat (limited to 'static')
-rw-r--r--static/upload.php9
1 files changed, 6 insertions, 3 deletions
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