本文整理汇总了PHP中GetImageExtension函数的典型用法代码示例。如果您正苦于以下问题:PHP GetImageExtension函数的具体用法?PHP GetImageExtension怎么用?PHP GetImageExtension使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetImageExtension函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
public function upload()
{
if (isset($_POST['Upload'])) {
$wkid = $this->input->post('id');
$image_name = $_FILES['image']['name'];
$image_size = $_FILES['image']['size'];
$image_type = $_FILES['image']['type'];
$tmp_name = $_FILES['image']['tmp_name'];
function GetImageExtension($imagetype)
{
if (empty($imagetype)) {
return false;
}
switch ($imagetype) {
case 'application/pdf':
return '.pdf';
default:
return false;
}
}
$ext = GetImageExtension($image_type);
//echo $ext;
if ($ext == false) {
$message = "Certificate is not in PDF format....Please upload again..!";
echo "<script type='text/javascript'>alert('{$message}.{$ext}');</script>";
echo "<script type='text/javascript'>window.close();</script>";
} else {
$imagename = date("d-m-Y") . "-" . time() . $ext;
$target_path = "pic/" . $image_name;
$finalpath = "/ims/{$target_path}";
if (move_uploaded_file($tmp_name, $target_path)) {
$imageinfo = array('path' => $finalpath, 'imagename' => $image_name);
// echo $finalpath;
$row = $this->work_model->geteqid($wkid);
// $temp=$row->path;
$tempimgname = $row->imagename;
// echo $tempimgname;
if ($tempimgname == 'no') {
unlink("pic/" . $tempimgname);
}
if ($this->work_model->updateimage($imageinfo, $wkid)) {
$message = " certificate uploaded sucessfully...!";
echo "<script type='text/javascript'>alert('{$message}');</script>";
} else {
echo 'gone';
}
// unlink("image/".$image_name);
} else {
$message = " Error {$ext} While uploading..Please choose file to upload!";
echo "<script type='text/javascript'>alert('{$message}');</script>";
exit("Please close this window and click on upload certificate to upload...! ");
}
echo "<script type='text/javascript'> window.close();</script>";
}
}
}
示例2: GetImageExtension
function GetImageExtension($imagetype)
{
if (empty($imagetype)) {
return false;
}
switch ($imagetype) {
case 'image/bmp':
return '.bmp';
case 'image/gif':
return '.gif';
case 'image/jpeg':
return '.jpg';
case 'image/png':
return '.png';
default:
return false;
}
}
if (!empty($_POST['arttitle']) && $_POST['artist_name'] && $_FILES["uploadedimage"]["name"]) {
$file_name = $_FILES["uploadedimage"]["name"];
$temp_name = $_FILES["uploadedimage"]["tmp_name"];
$imgtype = $_FILES["uploadedimage"]["type"];
$ext = GetImageExtension($imgtype);
$imagename = date("d-m-Y") . "-" . time() . $ext;
$target_path = "images/" . $imagename;
if (move_uploaded_file($temp_name, $target_path)) {
mysqli_query($mysqli, "INSERT INTO images_tbl (images_path,submission_date,image_category,artists,title,submission_time,image_status) VALUES ('" . $target_path . "','" . date("Y-m-d") . "','Photography','" . $_POST['artist_name'] . "','" . $_POST['arttitle'] . "','" . date("h:i:s") . "','Approved')");
} else {
exit("Error While uploading image on the server");
}
}
示例3: strip_tags
//variable to detect a successful image upload
$image_success = 1;
//extract testimonial data
$author = strip_tags($_POST['author']);
$date = strip_tags($_POST['date']);
$subject = strip_tags($_POST['subject']);
$subject = mysqli_real_escape_string($link, $subject);
$article = stripslashes($_POST['article']);
$article = mysqli_real_escape_string($link, $article);
//create image data
$tempName = $_FILES['image']['tmp_name'];
if (!($imageName = $_FILES['image']['name'])) {
echo "No Image Found<br>";
$image_success = 0;
} else {
if (!($imageExtension = GetImageExtension($_FILES['image']['type']))) {
$image_success = 0;
} else {
if ($_FILES['image']['size'] > 350000) {
$image_success = 0;
} else {
if (file_exists($targetPath = "articleimages/" . $imageName)) {
$image_success = 0;
} else {
if (!move_uploaded_file($tempName, $targetPath)) {
$image_success = 0;
}
}
}
}
}