Image upload standard code
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
$imgURL='';
if(isset($_FILES['dfile']['name']) && $_FILES['dfile']['name']!=''){
$allowed = array('gif','png' ,'jpg');
$filename = $_FILES['dfile']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$target_file='docs/'.time().rand(1111,9999).'.'.$ext;
if(!in_array($ext,$allowed) )
{
echo 'Please upload valid image';exit;
}
$check = getimagesize($_FILES["dfile"]["tmp_name"]);
if($check !== false) {
} else {
echo 'Please upload valid image';exit;
}
if (move_uploaded_file($_FILES["dfile"]["tmp_name"], $target_file)) {
$imgURL='https://www.betheball4u.com/'.$target_file;
$imgURL='<a href="'.$imgURL.'">'.$imgURL.'</a>';
}
}