This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > February 2006 > PHP & Image Manipulation - File Permissions?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author PHP & Image Manipulation - File Permissions?
crash

2006-02-12, 6:31 pm

I've got some problematic code that's interacting with a new server. I need
some PHP expertise to help me out with it. I did not develop the page, and
the only thing I really know about PHP is how to spell it.

Here is the errors that I am receiving & the code on the pages. I'm trying
to wade through this, but I'm not PHP native and I'm not sure I'm following
entirely what's going on. It appears to be a permissions issue - can
somebody help me with what permissions I might need to enable? I have
removed information I think might need to be, if it looks like you need some
of it, please let me know.

The error(s):

Warning: mkdir(../rental/rental_images/39): Permission denied in
/***/****/public_html/admin/admin_image_csize.php on line 60

Warning: Cannot modify header information - headers already sent by (output
started at /***/****/public_html/admin/admin_image_csize.php:60) in
/***/****/public_html/admin/admin_image_csize.php on line 61

Warning: chmod(): No such file or directory in
/***/***/public_html/admin/admin_image_csize.php on line 67

Warning: imagejpeg(): Unable to open '../rental/rental_images/39/Mayfield 2
BD.jpg' for writing in /***/****/public_html/admin/admin_image_csize.php on
line 83

Warning: chmod(): No such file or directory in
/***/****/public_html/admin/admin_image_csize.php on line 84

Warning: Cannot modify header information - headers already sent by (output
started at /***/****public_html/admin/admin_image_csize.php:60) in
/***/****/public_html/admin/adm_image_upload.php on line 17


The Code:
adm_image_updload.php - pulls in second file

<?
$photo_path = '../rental/rental_images';

// retrieves and opens Database info and upload script
include('include/database.php');
include('admin_image_csize.php');

//Replace any spaces in the foldername with %20

$folder = str_replace(" ", "%20", $_POST['folder_name']);

//Update Rental Table with Image Path Info
$query = "UPDATE rental SET photo_path =
'".urlencode(stripslashes($folder))."/".urlencode($_FILES['file']['name'])."'
WHERE rental_id = '".$_GET['id']."'";
$result = mysql_query($query) or die(mysql_error()."<br>$query");

// UPDATE THIS
header("Location: adm_listing.php");

?>

Admin_image_csize.php
$new_image = imagecreatetruecolor($width, $height);

// Set the background color of the thumbnail to white

$bgc = imagecolorallocate($new_image, 255,255,255);

// Fill the thumbnail with white...

imagefilledrectangle($new_image, 0,0,$thumbw, $thumbh, $bgc);

// Now copy the image from our originally loaded image ( or Thumb N/A
image)

imagecopyresampled ( $new_image, $orig, 0, 0, 0,0, $width, $height,
$size[0], $size[1]);

// Send the image to file.
// Here is where the actual file transfer takes place. If it is
unsuccessful then
// we give a halfway useful error message back to the user.
// First, let's check to make sure the folder exists


if (!is_dir($photo_path.'/'.stripslashes($folder_name))){
// if the folder does not exist, make it
if(!mkdir($photo_path.'/'.stripslashes($folder_name), 0775)) {
header("Location: #?error=no_directory");
}


}

chmod($photo_path.'/'.stripslashes($folder_name), 0775);

$file_name = current(explode('.', $_FILES['file']['name']));
$extension = end(explode('.', $_FILES['file']['name']));
$num = '';
while($num<100) {
if(is_file(stripslashes($photo_path."/".$folder_name.'/'.$file_name.$num.'.'.$extension)))
{
$num++;
} else {
$_FILES['file']['name'] = $file_name.$num.'.'.$extension;
break;
}
}

$_FILES['file']['name'] = stripslashes($_FILES['file']['name']);

imagejpeg($new_image,
$photo_path."/".stripslashes($folder_name).'/'.$_FILES['file']['name']);
chmod($photo_path."/".stripslashes($folder_name).'/'.$_FILES['file']['name'],0775); // Free up the memory used by gd to manipulate the images. imagedestroy($new_image); imagedestroy($orig);?>Thank you,Jon ParkhurstPriivaWebPO Box 1114Sedalia, MO 65302-
1114660.826.5600

Gary White

2006-02-12, 6:32 pm

On Wed, 8 Feb 2006 11:50:39 -0600, "crash" <crash@bcdcdigital.com>
wrote:

>adm_image_updload.php - pulls in second file
>
><?
>$photo_path = '../rental/rental_images';



What is the full, root-relative path to adm_image_upload.php?

Gary
crash

2006-02-12, 6:33 pm

I think I've got it Gary,k hold on just a few moments. If I haven't, I'll
post back.

"Gary White" <reply@newsgroup.please> wrote in message
news:effku1hcqml4m9atcl7ornu6ig9rhmdob0@4ax.com...
> On Wed, 8 Feb 2006 11:50:39 -0600, "crash" <crash@bcdcdigital.com>
> wrote:
>
>
>
> What is the full, root-relative path to adm_image_upload.php?
>
> Gary



crash

2006-02-12, 6:33 pm

I got it Gary. I thought file permissions were being set in the PHP file,
but apparently they needed to be set on the directory to allow it to set
permissions on the actual files.

Still learning all the ins and outs of PHP. Quite a mouthful.

Thanks for your attention, I really appreciate your quick response.

Jon

"Gary White" <reply@newsgroup.please> wrote in message
news:effku1hcqml4m9atcl7ornu6ig9rhmdob0@4ax.com...
> On Wed, 8 Feb 2006 11:50:39 -0600, "crash" <crash@bcdcdigital.com>
> wrote:
>
>
>
> What is the full, root-relative path to adm_image_upload.php?
>
> Gary



Gary White

2006-02-12, 6:33 pm

On Wed, 8 Feb 2006 13:43:40 -0600, "crash" <crash@bcdcdigital.com>
wrote:

>I think I've got it Gary,k hold on just a few moments. If I haven't, I'll
>post back.



Okay. Yell if you need help.

Gary
Gary White

2006-02-12, 6:33 pm

On Wed, 8 Feb 2006 14:07:13 -0600, "crash" <crash@bcdcdigital.com>
wrote:

>I got it Gary. I thought file permissions were being set in the PHP file,
>but apparently they needed to be set on the directory to allow it to set
>permissions on the actual files.


Yep. If the script doesn't have the permissions, it cannot *set* the
permissions. ;-)


>Still learning all the ins and outs of PHP. Quite a mouthful.
>
>Thanks for your attention, I really appreciate your quick response.


No problem, Jon. Post back if you need assistance in your journey.

Gary
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews