File "upload-ico.php"
Full Path: /home/u165092617/domains/tadzz.com/public_html/admin/upload-ico.php
File size: 1.19 KB
MIME-type: text/x-php
Charset: utf-8
<?php
// uploading files on submit
if(isset($_POST['submit'])){
// uploading files
$msg= upload_file();
session_start();
$_SESSION['msg-ico']= $msg;
header('location:text-file-upload.php');
}
function upload_file(){
$uploadTo = "../images/web-images/home/";
$allowFileType = array('png','jpg');
$fileName = $_FILES['file']['name'];
$tempPath=$_FILES["file"]["tmp_name"];
$basename = basename($fileName);
$name = str_replace("$basename ","favicon.png","$basename ");
$originalPath = $uploadTo.$name;
$fileType = pathinfo($originalPath, PATHINFO_EXTENSION);
if(!empty($fileName)){
if(in_array($fileType, $allowFileType)){
// Upload file to server
if(move_uploaded_file($tempPath,$originalPath)){
return $fileName." was uploaded successfully";
// write here sql query to store image name in database
}else{
$error = 'File Not uploaded ! try again';
}
}else{
return $fileType." file type not allowed";
}
}else{
return "Please Select a file";
}
}
?>