Search....

Tuesday 23 October 2018

A simple file upload code in php



<?php

if (isset($_POST['submit'])){

$file_name = $_FILES['fileToUpload']['name'];
$file_type = $_FILES["fileToUpload"]["type"];
$tmp_path = $_FILES["fileToUpload"]["tmp_name"];
$path = 'uploads/'.$file_name;
 
    move_uploaded_file($tmp_path, $path);

}

?>

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> File Upload </title>
</head>
<body align = "center">
<h1>File Upload</h1>
<form method="POST" action="" enctype="multipart/form-data">
<LABEL> Upload Your Image Here:</LABEL>
<br>
<input type="File" name="fileToUpload">
<br>
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>

No comments:

Post a Comment

Semester project - E commerce site - with source code

Here is the link to get soure code for semester project of ecommerce site. Click me to download