Author Topic: [SOLVED] permissions problem with imagejpeg()  (Read 591 times)

0 Members and 1 Guest are viewing this topic.

Offline evanctTopic starter

  • Enthusiast
  • Posts: 94
    • View Profile
[SOLVED] permissions problem with imagejpeg()
« on: July 01, 2009, 02:13:27 AM »
I have this function that creates thumbnails from uploaded images. It works fine until it hits imagejpeg():

"Warning: imagejpeg() [function.imagejpeg]: Unable to open '../users/evanct/57fc1272653226e790ae7e2e78705e3d/thumbnail' for writing: Permission denied in C:\Apache2\htdocs\fileservice\core\upload.php on line 32"

which is odd because I checked the permissions of the thumbnail directory and it's 0777, just as it should be. i even set its parents to 0777 to be sure, but i'm still getting the error. anyone know what the problem might be?

Offline evanctTopic starter

  • Enthusiast
  • Posts: 94
    • View Profile
Re: permissions problem with imagejpeg()
« Reply #1 on: July 01, 2009, 03:17:50 AM »
also happening with move_uploaded_file and the parent dir (../users/evanct/57fc1272653226e790ae7e2e78705e3d). this is frustrating.

Offline evanctTopic starter

  • Enthusiast
  • Posts: 94
    • View Profile
Re: permissions problem with imagejpeg()
« Reply #2 on: July 01, 2009, 02:25:23 PM »
bump

Offline flyhoney

  • Devotee
  • Posts: 845
  • Gender: Male
    • View Profile
    • blag
Re: permissions problem with imagejpeg()
« Reply #3 on: July 01, 2009, 02:27:22 PM »
I'm confused, the error you receive provides a Windows file path, but you say the permissions are 0777, which are unix file permissions.  Are you on a *nix or Windows machine?
"The enemy's gate is down." - Ender
error_reporting(E_ALL);          // place these two lines at the top of 
ini_set('display_errors'1);    // the script you are debugging

Offline evanctTopic starter

  • Enthusiast
  • Posts: 94
    • View Profile
Re: permissions problem with imagejpeg()
« Reply #4 on: July 01, 2009, 02:55:57 PM »
Well, by 0777 I just meant that full permissions were enabled for all users.

Offline flyhoney

  • Devotee
  • Posts: 845
  • Gender: Male
    • View Profile
    • blag
Re: permissions problem with imagejpeg()
« Reply #5 on: July 01, 2009, 03:00:52 PM »
Perhaps you should check to make sure your file path is correct.  You can do that using the file_exists() method.
Code: [Select]
<?php

if (file_exists('../users/evanct/57fc1272653226e790ae7e2e78705e3d/thumbnail'))
{
    die(
'yay');
}
else
{
    die(
'epic fail');
}

« Last Edit: July 01, 2009, 03:01:50 PM by flyhoney »
"The enemy's gate is down." - Ender
error_reporting(E_ALL);          // place these two lines at the top of 
ini_set('display_errors'1);    // the script you are debugging

Offline evanctTopic starter

  • Enthusiast
  • Posts: 94
    • View Profile
Re: permissions problem with imagejpeg()
« Reply #6 on: July 01, 2009, 04:59:51 PM »
Actually earlier in the code I already had a check to see if the directory exists, and if not, create it. it's definitely there.

Offline evanctTopic starter

  • Enthusiast
  • Posts: 94
    • View Profile
Re: permissions problem with imagejpeg()
« Reply #7 on: July 01, 2009, 05:53:08 PM »
Oh that was careless of me. I had simply forgotten that you need to add to the path the filename you want the file saved as.