Jump to content

Thumbnails without chmod 777


KicsiPet

Recommended Posts

Hi everyone!

I have a little bit of code. It won't work, because I cant set chmod to 777. The web host don't let me do it. So I thought about another way to create my thumbnails, jsut I don't know how to put it into my code. I figures move_uploaded_file() will work for me. So here is the code. I hope someone can help me with that. Thx

[code]
<?
$new_w = 100;
$cfg_fullsizepics_path = "pictures";
$cfg_thumb_path = "thumbs";
$filepath = "pictures";
$dir = dir($filepath);
while($entry=$dir->read()) {
if($entry == "." || $entry == "..") {
continue;
}
$fp = @fopen("$filepath/$entry","r");
$photo_filename = "$entry";
$image_stats = GetImageSize($cfg_fullsizepics_path."/".$entry);
$imagewidth = $image_stats[0];
$imageheight = $image_stats[1];
$img_type = $image_stats[2];
$ratio = ($imagewidth / $new_w);
$new_h = round($imageheight / $ratio);
if (!file_exists($cfg_thumb_path."/".$entry)) {
if ($img_type=="2") {
$src_img = imagecreatefromjpeg($cfg_fullsizepics_path."/".$entry);
$dst_img = imagecreate($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img, "$cfg_thumb_path"."/$entry");
} elseif ($img_type=="3") {
$dst_img=ImageCreate($new_w,$new_h);
$src_img=ImageCreateFrompng($cfg_fullsizepics_path."/".$entry);
ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
Imagepng($dst_img, "$cfg_thumb_path"."/$entry");
} elseif ($img_type=="1") {
$cfg_thumb_url=$cfg_fullsizepics_url;
}
}
echo "$entry";
echo "
";
}
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.