Jump to content

Recommended Posts

I have chmod'd the file using chmod($img, 0777) on upload and i have also chmod'd vid command prompt and still no joy please help :(


 

$il = explode("/",$_POST['image']);
$img = dirname(__FILE__)."/".$il[0]."/".$il[1]."/".$il[2]."/original/".$il[4]; #/var/www/users/Admin/photos/original/1334.jpg
$img1 = dirname(__FILE__)."/". $il[0]."/".$il[1]."/".$il[2]."/200x200/".$il[4];
$img2 = dirname(__FILE__)."/". $il[0]."/".$il[1]."/".$il[2]."/403x226/".$il[4];
$img3 = dirname(__FILE__)."/". $il[0]."/".$il[1]."/".$il[2]."/460x460/".$il[4];
 
unlink($img);
unlink($img1);
unlink($img2);
unlink($img3);
Edited by jbonnett
Link to comment
https://forums.phpfreaks.com/topic/277650-unlink-not-deleting-file/
Share on other sites

I have no error message's and I have tried with @unlink(), also I have tried with and without dirname(__FILE__)."/".

 at the start apart from that the path is good.

 

All I can think of is I use a form of copying the images to different sizes using...

 

 

    function resize($img, $width, $height, $stretch = false)
    {
        $temp = imagecreatetruecolor($width, $height);
        imagealphablending($temp, true);
        imagesavealpha($temp, true);
 
        $bg = imagecolorallocatealpha($temp, 0, 0, 0, 127); // Background color
        imagefill($temp, 0, 0, $bg);
 
        if ($stretch)
        {
            imagecopyresampled($temp, img, 0, 0, 0, 0, $width, $height, imagesx($img), imagesy($img)); 
        }
        else
        {          
            if (imagesx($img) <= $width && imagesy($img) <= $height)
            {
                $fwidth = imagesx($img);
                $fheight = imagesy($img);
            }
            else
            {
                $wscale = $width / imagesx($img);
                $hscale = $height / imagesy($img);
                $scale = min($wscale, $hscale);
                $fwidth = $scale * imagesx($img);
                $fheight = $scale * imagesy($img);
            }
            imagecopyresampled($temp,                             
                $img,                                      
                ($width - $fwidth) / 2, ($height - $fheight) / 2,   
                0, 0,                                              
                $fwidth, $fheight,                                 
                imagesx($img), imagesy($img)               
            );
        }
        return $temp; 
    }
 
$image = imagecreatefromjpeg(dirname(__FILE__)."/users/$session->username/photos/original/".$photo);
$resized = resize($image, 403, 226, false); // false = don't stretch
imagejpeg($resized, dirname(__FILE__)."/users/$session->username/photos/403x226/".$photo, 100);

 

 

 

chmod(dirname(__FILE__)."/users/$session->username/photos/original/".$photo, 0777);
chmod(dirname(__FILE__)."/users/$session->username/photos/200x200/".$photo, 0777);
chmod(dirname(__FILE__)."/users/$session->username/photos/460x460/".$photo, 0777);
chmod(dirname(__FILE__)."/users/$session->username/photos/403x226/".$photo, 0777);

 

Edited by jbonnett
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.