Upload image in php

#IMAGE UPLOAD

if ($_FILES['list1']['name'] != "") {

$allowed_ext = array("jpg", "jpeg", "png", "gif");

$extension = explode('.', $_FILES["list1"]["name"]);

$ext = strtolower(end($extension));

if (in_array($ext, $allowed_ext)) {

$newname = rand(10000, 99999) . "_" . time() . "." . $ext;

$loc = "upload/" . $newname;

move_uploaded_file($_FILES["list1"]["tmp_name"], "./" . $loc);

}

}

Leave a Reply

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