Permalink
Browse files

Added sample script and sample configuration for unzip filter

  • Loading branch information...
1 parent d1ff206 commit 83434508b406b3073a48053875d8e75f9940abec @vkholodkov committed Oct 28, 2008
Showing with 60 additions and 6 deletions.
  1. +54 −0 example-unzip.php
  2. +6 −2 nginx-unzip.conf
  3. +0 −4 nginx.conf
View
@@ -0,0 +1,54 @@
+<?php
+$header_prefix = 'file';
+?>
+<html>
+<head>
+<title>Test upload</title>
+</head>
+<body>
+<?
+if ($_POST){
+ echo "<h2>Uploaded files:</h2>";
+
+ echo "<table border=\"2\" cellpadding=\"2\">";
+
+ echo "<tr><td>Archive path</td><td>File name</td><td>Location</td><td>Content type</td><td>MD5</td><td>Size</tr>";
+
+ $fdesc_keys = array_keys($_POST);
+
+ foreach($fdesc_keys as $fdesc_key) {
+ if(strpos($fdesc_key, $header_prefix) == 0 &&
+ strpos($fdesc_key, "_name") > 0) {
+ $key = substr($fdesc_key, 0, count($fdesc_key) - 6);
+
+ if (array_key_exists($key."_name", $_POST) && array_key_exists($key."_path",$_POST)) {
+ $archive_path = $_POST[$key."_archive_path"];
+ $tmp_name = $_POST[$key."_path"];
+ $name = $_POST[$key."_name"];
+ $content_type = $_POST[$key."_content_type"];
+ $md5 = $_POST[$key."_md5"];
+ $size = $_POST[$key."_size"];
+
+ echo "<tr><td>$archive_path</td><td>$name</td><td>$tmp_name</td><td>$content_type</td><td>$md5</td><td>$size</td>";
+ }
+ }
+ }
+
+ echo "</table>";
+
+}else{?>
+<h2>Select files to upload</h2>
+<form name="upload" method="POST" enctype="multipart/form-data" action="/upload">
+<input type="file" name="file1"><br>
+<input type="file" name="file2"><br>
+<input type="file" name="file3"><br>
+<input type="file" name="file4"><br>
+<input type="file" name="file5"><br>
+<input type="file" name="file6"><br>
+<input type="submit" name="submit" value="Upload">
+<input type="hidden" name="test" value="value">
+</form>
+<?}
+?>
+</body>
+</html>
View
@@ -41,10 +41,14 @@ http {
upload_pass_form_field "^submit$|^description$";
- upload_cleanup 400-599;
+ upload_cleanup 404 500-505;
upload_filter application/zip {
- upload_unzip on;
+ upload_unzip;
+ }
+
+ upload_filter application/java-archive {
+ upload_unzip;
}
}
View
@@ -39,10 +39,6 @@ http {
upload_aggregate_form_field "${upload_field_name}_size" $upload_file_size;
upload_pass_form_field "^submit$|^description$";
-
- upload_filter "application/zip" {
- unzip on;
- }
}
# Pass altered request body to a backend

0 comments on commit 8343450

Please sign in to comment.