0

when i have tried to deploy a php project in another system i got a error like this

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'image.jpg' for writing: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/WISMAN/pmhome.php on line 61

here i am getting a json after calling a web service to get a json as a response which contains a image in the string form,which i am encoding it into an image and saving it as image.jpeg but shows this one

 <?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');
} ?>
Sree
  • 41
  • 1
  • 1
  • 8

3 Answers3

1

You just don't have enough privileges for writing to destination folder. Your server is probably running under user apache, httpd or something like that and you have your user like Sree.

Therefore you have to be either in one group and have chmod set to x7x - writeable for group; or (not in the same group) xx7 - writeable for all.

Not mentioning possible issues caused by seLinux (which your system may be running).

Vyktor
  • 20,559
  • 6
  • 64
  • 96
0

You don't have a write permission to your directory. Give it permission then it should work.

chandresh_cool
  • 11,753
  • 3
  • 30
  • 45
0

Your application does not have write permissions in the target directory that you are trying to save the file into. you will need to log in using a secure shell and update the permissions using chmod

FastGeek
  • 411
  • 2
  • 7