How to upload file or image in html form using php

How to upload file or image in html form using php

The source code of uploading a file is given below.


<?php
error_reporting(0);
?>

<html>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="uploadfile" value="">
<input type="submit" name="submit" value="Upload File">
</form>
</body>
</html>
<?php
$folder="student/";
$filename=$_FILES["uploadfile"]["name"];
$tempname=$_FILES["uploadfile"]["tmp_name"];
$folder="student/".$filename; // To save the image at folder student/image_name
//echo $folder;
move_uploaded_file($tempname,$folder);//temp location to destination
echo "<img src='$folder' height='100' width='100'/>" //This code is for showing the uploaded image
?>

Comments

Popular posts from this blog

how to compile multiple file in java using single command

Ternary operator and Nested Ternary operator

How to pass argument in main function of java program using command line argument