Skip to content

Instantly share code, notes, and snippets.

@Eboubaker
Last active August 19, 2022 19:26
Show Gist options
  • Save Eboubaker/176c12983150f4d468dd8976e6f10543 to your computer and use it in GitHub Desktop.
Save Eboubaker/176c12983150f4d468dd8976e6f10543 to your computer and use it in GitHub Desktop.
Serve files in the current directory to the network.
<?php
$files = array_diff(scandir('.'), ['.', '..', 'index.php']);
if(empty($files)) die("no files in directory .");
foreach ($files as $f) {
echo "<div style='font-size: 1.3em;padding-left: 15px'><a href='$f'>$f</a></div>";
}
@echo off
xcopy %~dp0\index.php "%cd%" /Y
php -S 0.0.0.0:2000 -t "%cd%"
@Eboubaker
Copy link
Author

Eboubaker commented Mar 22, 2022

put index.php in the same folder as serve.bat.
then add server.bat to PATH.
then call command serve anywhere to serve any files in the cmd directory to the network on port 2000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment