file upload directory permissions problem?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
conundrum
Forum Newbie
Posts: 15
Joined: Sun Jun 29, 2003 12:18 pm
Location: Ontario, Canada

file upload directory permissions problem?

Post by conundrum »

I have an admin seciton on my site which allows records to be added along with image files (for a slideshow). When a record is added, the images are uploaded and counted and everything works well.

I have a change routine which allows details to be changed as well as changes allowing the user to change a current image or add extras. If an image is to be overwritten it should leave the slide count the same, if it is an additional image, it adds to the count etc...

It works on localhost on my machine, but on the ISP's server it does not. The add, routine works fine, and the change works if you change the details, but not the images. If I try to add a NEW image, it creates a 0 byte file with the proper name and won't copy the file up.

Is this a permissions problem? I have CHMODed the images directory 0777. The funny thing is that it works for adding a brand new record, but not when you want to change images or add images to an existing record.

You may want to see the code?
conundrum
Forum Newbie
Posts: 15
Joined: Sun Jun 29, 2003 12:18 pm
Location: Ontario, Canada

Post by conundrum »

function upload($img, $name, $f){
if(copy($img, "../images/".$name.$f.".jpg")){
echo("Slide $f was successfully uploaded!<p>\n");
}else{
echo("Slide $f could not be copied<p>\n");
}
unlink($img);
}

//A FUNCTION TO RESIZE THE IMAGE
function resize($i,$newWidth,$path,$newName) {
$img=imagecreatefromjpeg("$i");
$oldWidth=imagesx($img);
$oldHeight=imagesy($img);
$scale=$newWidth/$oldWidth;
$newHeight=ceil($oldHeight*$scale);
$newimg=imagecreate($newWidth,$newHeight);
imagecopyresized($newimg,$img,0,0,0,0,$newWidth,$newHeight,$oldWidth,$oldHeight);
imagejpeg($newimg, $path.$newName);
return true;
}

if($slide1){//<input type=file name=slide1 size=20>
$f=1; //counter, first slide is set to 1
upload($slide1, $image, $f);
resize("../images/".$image.$f.".jpg",450,"../images/",$image.$f.".jpg");
if($f<=$slideshow){ //nochange to slideshow count
}else{
$newSlideshow++;
}
}
llama
Forum Commoner
Posts: 44
Joined: Fri Jun 27, 2003 8:30 am
Location: Texas

Post by llama »

What sort of images are you loading?
conundrum
Forum Newbie
Posts: 15
Joined: Sun Jun 29, 2003 12:18 pm
Location: Ontario, Canada

Post by conundrum »

I am in real estate and I am modifiying the administration section of our site to allow myself and my partner add/change/delete listings from our site. So every property has 1 front picture and when we add a new listing we have the option of selecting 1 or more other pictures to create a slideshow. That all works well. The problem arises when I go to change an existing listing. I can change the text details, but if I try to change a current picture or add a new one it doesn't work. It begins the "upload" function I have set up, but doesn't copy the file up. Instead it says "Slide# could not be copied". Any ideas? Should I elaborate more? Anyone?
Post Reply