在另一个系统上部署PHP项目时,显示权限被拒绝的错误


on deploying php project on another system shows an error as permission denied

当我尝试在另一个系统中部署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

在这里,我得到一个json调用web服务后,得到一个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');
} ?>

您只是没有足够的权限写入目标文件夹。您的服务器可能在用户apache, httpd或类似的用户下运行,而您的用户为Sree

因此,您必须在一个组中并将chmod设置为x7x -可写组;或(不在同一组)xx7 -可写。

没有提及seLinux(您的系统可能正在运行)可能引起的问题。

您没有对目录的写权限。

您的应用程序在您试图保存文件的目标目录中没有写权限。您需要使用安全shell登录,并使用chmod

更新权限。