php

Create The Upload File PHP Script

I want to upload file to a given folder.

<?php

(1) if(isset($_FILES[‘image’])){ // This name (image) is use to input name line no 15.
(2) echo”<pre>”;

(3) print_r($_FILES);

(4) echo”<pre>”;

(5) echo dirname(__FILE__);

//4 arrays are provides name, size, tmp_name, type is mandatory.

$file_name = $_FILES[‘image’][‘name’];
$file_size = $_FILES[‘image’][‘size’];
$file_tmp = $_FILES[‘image’][‘tmp_name’];
$file_type = $_FILES[‘image’][‘type’];

(6) move_uploaded_file($file_tmp,dirname(__FILE__).”/uploads-images/”.$file_name);
}

?>

(8)<html>

(9)<head>

(10)<title>File upload </title>

(11)</head>

(12) <body>

(13) <form action =”” method =”post” enctype=”multipart/form-data”>

(14) Select image to upload:

(15) <input type =”file” name = “image” id =”image”>

(16) <input type = ” submit”/>

(17) </form>

(18) </body>

Related Articles

Leave a Reply

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

Back to top button