summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--static/upload.php7
2 files changed, 5 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1946f6c..18ba511 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Missing essential PHP includes and classes are now errors (`require_once`)
instead of warnings (`include_once`). (Austin Gillmann)
- Non-abuse contact email to <info@pantsu.cat>. (Juuso Lapinlampi)
+- `upload_file()` will no longer attempt to remove temporary files manually.
+ Temporary files are automatically garbage collected by PHP. (Juuso Lapinlampi)
### Deprecated
diff --git a/static/upload.php b/static/upload.php
index ebedeab..4b1f73d 100644
--- a/static/upload.php
+++ b/static/upload.php
@@ -112,8 +112,9 @@ function upload_file($file)
throw new UploadException($file->error);
}
- // Check if a file with the same hash and size (a file which is the same) does already exist in
- // the database; if it does, delete the file just uploaded and return the proper link and data.
+ // Check if a file with the same hash and size (a file which is the same)
+ // does already exist in the database; if it does, return the proper link
+ // and data. PHP deletes the temporary file just uploaded automatically.
$q = $db->prepare('SELECT filename, COUNT(*) AS count FROM files WHERE hash = (:hash) '.
'AND size = (:size)');
$q->bindValue(':hash', $file->get_sha1(), PDO::PARAM_STR);
@@ -121,8 +122,6 @@ function upload_file($file)
$q->execute();
$result = $q->fetch();
if ($result['count'] > 0) {
- unlink($file->tempfile);
-
return array(
'hash' => $file->get_sha1(),
'name' => $file->name,