Add support of pretty url

This commit is contained in:
Beu 2019-10-23 17:22:25 +02:00
parent f27d42a92a
commit f2ba5a4d7f
3 changed files with 18 additions and 6 deletions

View File

@ -4,4 +4,5 @@
define('_HTTP_DOMAIN','localhost:8080'); // domain/IP with port if needed define('_HTTP_DOMAIN','localhost:8080'); // domain/IP with port if needed
define('_HTTP_PATH','/'); define('_HTTP_PATH','/');
define('_SIZE_LIMIT','2000000'); // in bytes define('_SIZE_LIMIT','2000000'); // in bytes
define('_PRETTY_URL', false);
?> ?>

View File

@ -31,12 +31,12 @@ Drag and Drop your file or <input class="button" type="button" value="Select Fil
This tool is usable with <b>curl</b> or <b>wget</b>.<br><br> This tool is usable with <b>curl</b> or <b>wget</b>.<br><br>
To upload : <br> To upload : <br>
<li> curl --upload-file ./hello.txt <?php print(_HTTP_PROTO . '://' . _HTTP_DOMAIN . _HTTP_PATH . 'index.php?name=hello.txt');?><br> <li> curl --upload-file ./my_file <?php print($uploadurl);?><br>
<li> wget -q --body-file='./hello.txt' --method=PUT -O - <?php print(_HTTP_PROTO . '://' . _HTTP_DOMAIN . _HTTP_PATH . 'index.php?name=hello.txt');?><br><br> <li> wget -q --body-file='./my_file' --method=PUT -O - <?php print($uploadurl);?><br><br>
To download file :<br> To download file :<br>
<li> curl -OJ <?php print(_HTTP_PROTO . '://' . _HTTP_DOMAIN . _HTTP_PATH . 'index.php?id=99999');?><br> <li> curl -OJ <?php print($downloadurl . '99999');?><br>
<li> wget --content-disposition <?php print(_HTTP_PROTO . '://' . _HTTP_DOMAIN . _HTTP_PATH . 'index.php?id=99999');?> <li> wget --content-disposition <?php print($downloadurl . '99999');?>
</div> </div>
</div> </div>

View File

@ -23,6 +23,17 @@
} }
if (_PRETTY_URL === true)
{
$downloadurl = _HTTP_PROTO . '://' . _HTTP_DOMAIN . _HTTP_PATH ;
$uploadurl = $downloadurl ;
}
else
{
$downloadurl = _HTTP_PROTO . '://' . _HTTP_DOMAIN . _HTTP_PATH . 'index.php?id=' ;
$uploadurl = _HTTP_PROTO . '://' . _HTTP_DOMAIN . _HTTP_PATH . 'index.php?name=my_file' ;
}
// Upload File // Upload File
if ($_SERVER['REQUEST_METHOD'] === 'PUT') if ($_SERVER['REQUEST_METHOD'] === 'PUT')
{ {
@ -50,7 +61,7 @@
if ($filesize < _SIZE_LIMIT ) if ($filesize < _SIZE_LIMIT )
{ {
print(_HTTP_PROTO . '://' . _HTTP_DOMAIN . _HTTP_PATH . 'index.php?id=' . $rnd_data ); print($downloadurl . $rnd_data );
} }
else else
{ {
@ -93,7 +104,7 @@
{ {
if (stristr($_SERVER["HTTP_USER_AGENT"], 'curl') or stristr($_SERVER["HTTP_USER_AGENT"], 'Wget')) if (stristr($_SERVER["HTTP_USER_AGENT"], 'curl') or stristr($_SERVER["HTTP_USER_AGENT"], 'Wget'))
{ {
print("To upload file, use # curl --upload-file my_file " . _HTTP_PROTO . '://' . _HTTP_DOMAIN . _HTTP_PATH . "index.php?name=my_file\n"); print("To upload file, use # curl --upload-file my_file " . $uploadurl);
} }
else else
{ {