diff --git a/public_html/.htaccess b/public_html/.htaccess
index 26771e96..7e5f4514 100644
--- a/public_html/.htaccess
+++ b/public_html/.htaccess
@@ -1,5 +1,8 @@
RewriteEngine On
+# Always rewrite tmp file access
+RewriteRule ^(tmp/.*)$ index.php?REQUESTED_URL=$1 [L,QSA]
+
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# If the request is not for a valid link
diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php
index c1840c72..c12dbbdb 100644
--- a/public_html/includes/class/class.LSsession.php
+++ b/public_html/includes/class/class.LSsession.php
@@ -2369,6 +2369,24 @@ class LSsession {
return False;
}
+ /**
+ * Retourne le chemin du fichier temporaire à partir du nom du fichier (s'il existe)
+ *
+ * @author Benjamin Renard
+ *
+ * @param[in] $hash La valeur du fichier
+ *
+ * @retval mixed
+ **/
+ public static function getTmpFileByFilename($filename) {
+ foreach(self :: $tmp_file as $filePath => $contentHash) {
+ if (basename($filePath) == $filename) {
+ return $filePath;
+ }
+ }
+ return False;
+ }
+
/**
* Supprime les fichiers temporaires
*
diff --git a/public_html/includes/routes.php b/public_html/includes/routes.php
index 37a557f0..78b83a26 100644
--- a/public_html/includes/routes.php
+++ b/public_html/includes/routes.php
@@ -249,6 +249,22 @@ function handle_image($request) {
}
LSurl :: add_handler('#^image/(?P[^/]+)$#', 'handle_image', false);
+/*
+ * Handle tmp file request
+ *
+ * @param[in] $request LSurlRequest The request
+ *
+ * @retval void
+ **/
+function handle_tmp_file($request) {
+ $path = LSsession :: getTmpFileByFilename($request -> filename);
+ if ($path && is_file($path)) {
+ dumpFile($path);
+ }
+ LSurl :: error_404($request);
+}
+LSurl :: add_handler('#^tmp/(?P[^/]+)$#', 'handle_tmp_file');
+
/*
************************************************************
* LSobject views