当我试图在另一个系统中部署一个 php 项目时,我遇到了这样的错误
Warning: imagejpeg() [function.imagejpeg]: Unable to open 'image.jpg' for writing: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/WISMAN/pmhome.php on line 61
在这里,我在调用 Web 服务以获取 json 作为响应后得到一个 json,其中包含字符串形式的图像,我将其编码为图像并将其保存为 image.jpeg 但显示了这个
<?php
$userid=$_SESSION[user_id];
//echo $userid;
$useridofuser=array(
'user_id'=> "$userid");
//echo json_encode($useridofuser);//coverting the vlaues collected from form into json
//calling the web service
$url='webservice url';
$data=$useridofuser;
//echo("Input to Server : ".$data."\n");
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($useridofuser));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$response= curl_exec($ch);
echo('\n'."Server response : \n \n".$response);
curl_close($ch);
//parsing the json response from server
$jsonde="$response";
$json_o=json_decode($jsonde);
$json_a=json_decode($jsonde,true);
//echo("$json_a");
$company_name=$json_a[user_data][company_name];
$name=$json_a[user_data][name];
$registration_date=$json_a[user_data][registration_date];
$user_id=$json_a[user_data][user_id];
$product_id=$json_a[product_data][0][product_id];
$product_registration_id=$json_a[product_data][0][product_registration_id];
$product_name=$json_a[product_data][0][product_name];
$registration_date=$json_a[product_data][0][registration_date];
$image=$json_a[product_data][0][image];
$expiry_date=$json_a[product_data][0][expiry_date];
$product_evaluation_level=$json_a[product_data][0][product_evaluation_level];
$_SESSION[regid]=$product_registration_id;
if($product_evaluation_level=="1")
{
$level=trial;
}
$image_base64="$image";
$img = imagecreatefromstring(base64_decode($image_base64));
if($img != false)
{
imagejpeg($img, 'image.jpg');
} ?>