try { if($_FILES["file"]){ move_uploaded_file($_FILES["file"]["tmp_name"], "./img/test.jpg"); } } catch(Exception $e){ echo "error:", $e->getMessage().PHP_EOL; } ?> <body> <form action="" method="POST" enctype="multipart/form-data"> <input type="file" name="file"> <input type="submit" value="upload"> </form> </body>