0
腳本否認顯示這條消息上傳image.Please幫助警告:imagejpeg()[function.imagejpeg]:無法打開 'broadcast_news_images/13331558akantony2.jpg' 寫:權限
警告時:imagejpeg() [function.imagejpeg]:無法打開 'broadcast_news_images/13331558akantony2.jpg' 寫入:權限在d拒絕:\的Inetpub \虛擬主機\ gallinews.com \的httpdocs \ adminpanel \ imgcrop.php第19行
Warning: chmod() [function.chmod]: Permission denied in D:\inetpub\vhosts\gallinews.com\httpdocs\adminpanel\imgcrop.php on line 19
//這是imgcrop.php文件
<?php
class SimpleImage
{
var $image; var $image_type;
function load($filename)
{
$image_info = getimagesize($filename);
$this->image_type = $image_info[2];
if($this->image_type == IMAGETYPE_JPEG)
{
$this->image = imagecreatefromjpeg($filename);
}
elseif($this->image_type == IMAGETYPE_GIF)
{
$this->image = imagecreatefromgif($filename);
} elseif($this->image_type == IMAGETYPE_PNG)
{ $this->image = imagecreatefrompng($filename); } }
function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { if($image_type == IMAGETYPE_JPEG) { imagejpeg($this->image,$filename,$compression); } elseif($image_type == IMAGETYPE_GIF) { imagegif($this->image,$filename); } elseif($image_type == IMAGETYPE_PNG) { imagepng($this->image,$filename); } if($permissions != null) { chmod($filename,$permissions); } } //Line number 19 error
function output($image_type=IMAGETYPE_JPEG)
{
if($image_type == IMAGETYPE_JPEG)
{
imagejpeg($this->image);
}
elseif($image_type == IMAGETYPE_GIF)
{
imagegif($this->image);
}
elseif($image_type == IMAGETYPE_PNG)
{
imagepng($this->image);
}
}
function getWidth()
{
return imagesx($this->image);
}
function getHeight()
{
return imagesy($this->image);
}
function resizeToHeight($height)
{
$ratio = $height/$this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width,$height);
}
function resizeToWidth($width)
{
$ratio = $width/$this->getWidth();
$height = $this->getheight() * $ratio;
$this->resize($width,$height);
}
function scale($scale)
{
$width = $this->getWidth() * $scale/100;
$height = $this->getheight() * $scale/100;
$this->resize($width,$height);
}
function resize($width,$height)
{
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}
}
// include('SimpleImage.php');
?>
This is the file where i use imgcrop file.
<?php
include 'connect.php';
include 'unset_user.php';
?>
<?php
include('imgcrop.php');
$errflag=false;
if(isset($_POST['edit_broadcast_news']))
{
function clean($str)
{
$str = @trim($str);
if(get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
if(isset($_POST['bdn_id']) && $_POST['bdn_id']!='')
{
$bdn_id=clean($_POST['bdn_id']);
}
if(isset($_POST['bdn_title']) && $_POST['bdn_title']!='')
{
$bdn_title=clean($_POST['bdn_title']);
}
else
{
$errflag=true;
$broadcast_news_edit_err[]="Please Enter News Title";
}
if(isset($_POST['bdn_desc']) && $_POST['bdn_desc']!='')
{
$bdn_desc=clean($_POST['bdn_desc']);
}
else
{
$errflag=true;
$broadcast_news_edit_err[]="Please Enter News Description";
}
if(isset($_POST['full_image']) && $_POST['full_image']!='')
{
$full_image=clean($_POST['full_image']);
}
if(isset($_POST['b_news']) && $_POST['b_news']!='')
{
$b_news=clean($_POST['b_news']);
}
if(isset($_POST['bdn_status']) && $_POST['bdn_status']!='')
{
$bdn_status=clean($_POST['bdn_status']);
}
else
{
$errflag=true;
$broadcast_news_edit_err[]="Please Select Status ";
}
if(isset($_POST['obdn_image']) && $_POST['obdn_image']!='')
{
$obdn_image=clean($_POST['obdn_image']);
}
if(empty($_FILES['bdn_image']['name']))
{
}
else
{
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["bdn_image"]["name"]);
$extension = end($temp);
if ((($_FILES["bdn_image"]["type"] == "image/gif")
|| ($_FILES["bdn_image"]["type"] == "image/jpeg")
|| ($_FILES["bdn_image"]["type"] == "image/jpg")
|| ($_FILES["bdn_image"]["type"] == "image/pjpeg")
|| ($_FILES["bdn_image"]["type"] == "image/x-png")
|| ($_FILES["bdn_image"]["type"] == "image/png"))
/*&& ($_FILES["bdn_image"]["size"] < 1000000)*/
&& in_array($extension, $allowedExts))
{
if ($_FILES["bdn_image"]["error"] > 0)
{
$prod_add_err[]=$_FILES["bdn_image"]["error"] . "<br>";
$errflag=true;
}
else
{
}
}
else
{
}
}
if($errflag==true)
{
$_SESSION['broadcast_news_edit_err']=$broadcast_news_edit_err;
//header("location:edit_broadcast_news.php?bdn_id=$bdn_id");
print_r($broadcast_news_edit_err);
}
else
{
$tmpFilePath = $_FILES['bdn_image']['tmp_name'];
if ($tmpFilePath != "")
{
$imgname=rand(0000,9999).$_FILES["bdn_image"]["name"];
$image = new SimpleImage();
$image->load($tmpFilePath);
$image->resize(1024,768);
$image->save('broadcast_news_images/'.$imgname);
}
else
{
$imgname=$obdn_image;
echo "2";
}
//,bdn_date=curdate()
//g_id, g_name, g_position, g_status, g_flag
$add_bd=mysql_query("update broadcast_news set bdn_title='$bdn_title', bdn_desc='$bdn_desc', bdn_image='$imgname',full_img_disp='$full_image', bdn_status='$bdn_status' where bdn_id='$bdn_id'");
if($add_bd)
{
if($imgname==$obdn_image)
{
}
else
{
@unlink('broadcast_news_images/'.$obdn_image.'');
}
echo 123;
$_SESSION['broadcast_news_edit_success']="Broadcast News Edited Successfully";
//header("location:edit_broadcast_news.php?bdn_id=$bdn_id");
//exit();
}
else
{
echo 32;
unlink('broadcast_news_images/'.$imgname.'');
$_SESSION['broadcast_news_edit_err']="Broadcast News Not Edited.Please Try Again";
//header("location:edit_broadcast_news.php?bdn_id=$bdn_id");
//exit();
}
}
}
else
{
echo "df";
}
?>
文件,不有權檢查許可,並給予書面許可。 –