| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/citysuper/webadmin/ |
Upload File : |
<?php
require_once("check_login.php");
require_once("function_cropimg.php");
require_once("mime_type_lib.php");
$message = "";
if (empty($_FILES["logo_img"]['name'])) {
$message .= "Please select a image.\\n\\n";
}
if (!empty($message)) {
echo "<script>alert('" . $message . "'); history.back();</script>";
exit;
}
$id = $_POST["id"];
$sql = "select * from logo where id = ?";
$parameters = array($id);
$logo_info = bind_pdo($sql, $parameters, "selectone");
// Upload File
$filelimit = 2 * 1048576; //Filelimit in 2MB
if ($_FILES["logo_img"]['name'] <> '') {
if ($_FILES["logo_img"]['size'] < $filelimit) {
//check if image type is valid or not
$mime = get_file_mime_type($_FILES["logo_img"]['name']);
if (($mime == "image/gif") || ($mime == "image/jpeg") || ($mime == "image/png")) {
$filename = $_FILES["logo_img"]['name'];
preg_match("/\.([^\.]+)$/", $filename, $file_ext);
$newfilename = random_string() . "_id_" . $id . "." . $file_ext[1]; // default length 8
move_uploaded_file($_FILES["logo_img"]['tmp_name'], "../images/logo/" . $newfilename) or die ("Could not copy the file");
//$logo_imgpath = "../images/slideshow/".$newfilename;
//createthumb($logo_imgpath, $logo_imgpath, 680, 350);
$logo_img = $newfilename;
} else {
echo '<script language="javascript">
alert("Files must be JPEG, GIF, or PNG and under 2MB in size");
history.back();
</script>';
exit;
}
} else {
echo '<script language="javascript">
alert("Files must be JPEG, GIF, or PNG and under 2MB in size");
history.back();
</script>';
exit;
}
} else {
$logo_img = "";
}
$sql = "update logo set logo_img=?, lastupdate=?, lastupby=? where id=?";
$parameters = array($logo_img, $nowdate, $_SESSION['cmsloginid'], $id);
bind_pdo($sql, $parameters);
if (!empty($logo_img) || $_POST["delimage"] > 0) {
$targetfilepath = "../images/logo/" . $logo_info["logo_img"];
if (is_file($targetfilepath)) {
unlink($targetfilepath);
}
}
$dbh = null;
header("Location: logo_index.php?msg=Modify Successfully");