Make your own WiFi file transfer system – Simple HTML and PHP local file upload script

Let’s say we have our local webserver, in my case I use XAMPP so I can have a local web in my localhost.

Then, by accessing this local web page over wifi from my mobile phone web browser, I can upload some files from my phone to the local web server.

This way I can send file wirelessly from my phone to my PC just by visiting my local web page.

In case you need something like this, please have this php script in your localhost:

<!DOCTYPE html>
<html>
	<head>
		<title>Uploads</title>
	</head>
	<body>
		
		<?php
		if(isset($_POST['upload'])){
			$target_dir = "uploads/";
			if (!file_exists($target_dir)) {
				mkdir($target_dir);
			}
			
			$target_file = $target_dir . basename($_FILES["userfile"]["name"]);
			move_uploaded_file($_FILES["userfile"]["tmp_name"], $target_file);
			 
			echo "File uploaded!";
		}else{
			?>
			<form method="POST" enctype="multipart/form-data">
				<label>Select File</label>
				
				<input name="userfile" type="file"/>
				<br><br>
				
				<input type="submit" name="upload" value="Upload">
			</table>
			</form>
			<?php
		}
		?>
	
		
	</body>
</html>

Then access it over wifi from your any devices you have, but don’t forget to change the “localhost” with the local server ip address.

To avoid confusion, I will demonstrate it in a video: (coming soon).

Leave a Reply

Your email address will not be published. Required fields are marked *