PHP file upload process

Let’s upload the file while looking at the simplest code.

test.php

<form action="test2.php" enctype="multipart/form-data" method="post">
	<input name="file_upload" type="file">
	<input type="submit" value="upload">
</form>

test2.php

	$upload = './'.$_FILES['file_upload']['name'];
	if(move_uploaded_file($_FILES['file_upload']['tmp_name'], $upload)){
		echo 'upload success';
	} else {
		echo 'upload failed';
	}

well done.