jbonnett Posted May 5, 2013 Share Posted May 5, 2013 (edited) 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 May 5, 2013 by jbonnett Quote Link to comment https://forums.phpfreaks.com/topic/277650-unlink-not-deleting-file/ Share on other sites More sharing options...
requinix Posted May 5, 2013 Share Posted May 5, 2013 If it's not deleting it (them) then there's probably an error message (or four)... You're sure the "image" from the form is actually "users/Admin/photos/1334.jpg"? Quote Link to comment https://forums.phpfreaks.com/topic/277650-unlink-not-deleting-file/#findComment-1428335 Share on other sites More sharing options...
jbonnett Posted May 5, 2013 Author Share Posted May 5, 2013 (edited) 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 May 5, 2013 by jbonnett Quote Link to comment https://forums.phpfreaks.com/topic/277650-unlink-not-deleting-file/#findComment-1428349 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.