Skip to content

Instantly share code, notes, and snippets.

@Miopas
Created July 27, 2018 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Miopas/09df8dbf3b85ec61069f9a12d729bb27 to your computer and use it in GitHub Desktop.
Save Miopas/09df8dbf3b85ec61069f9a12d729bb27 to your computer and use it in GitHub Desktop.
nginx upload php script
<?php
$header_prefix = 'file';
$slots = 6;
?>
<html>
<head>
<title>Test upload</title>
</head>
<body>
<?php
if ($_POST){
echo "<h2>Uploaded files:</h2>";
echo "<table border=\"2\" cellpadding=\"2\">";
echo "<tr><td>Name</td><td>Location</td><td>Content type</td><td>MD5</td><td>Size</td><td>Scp Command</td><td>Wget Command</tr>";
for ($i=1;$i<=$slots;$i++){
$key = $header_prefix.$i;
if (array_key_exists($key."_name", $_POST) && array_key_exists($key."_path",$_POST)) {
$tmp_name = $_POST[$key."_path"];
$name = $_POST[$key."_name"];
$content_type = $_POST[$key."_content_type"];
$md5 = $_POST[$key."_md5"];
$size = $_POST[$key."_size"];
$final_path = "/export/share/upload";
if (rename($tmp_name, "$final_path/$name")) {
echo "SUCCESS!";
} else {
echo "FAIL!";
}
$scp_cmd = "scp team@***:/export/share/upload/$name .";
$wget_cmd = "wget http://***/files/upload/$name";
echo "<tr><td>$name</td><td>$final_path</td><td>$content_type</td><td>$md5</td><td>$size</td><td>$scp_cmd</td><td>$wget_cmd</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>
<?php
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment