I'm having a bitch of a time with the below code. It has been running fine for a while on several of my sites, now im trying to combine it with an image resize, and it's suddenly decided to refuse to upload...... I have no idea why...
fileUpload($img,$img_name,$abpath,$debug)
{
// $abpath is absolute path to where images are uploaded. No trailing slash eg $abpath = "/usr/local/etc/httpd/vhosts/user/images";
$url = "http://www.url.com/images"; //Url to where images are uploaded. No trailing slash
$sizelim = "no"; //Do you want size limit, yes or no
$size = "60000"; //What do you want size limited to be if there is one
if($debug==1){echo"Path=$abpath<br>URL:$url<p>Image:$img<p>Image_name: $img_name<p>Img_size:$img_size<p>";}
//checks if file was selected to upload
if ($img == 'none') {
echo("No image selected for upload.<br>");
}
else
{
if ($sizelim == "yes") {
if ($img_size > $size) {
die("<b>Error</b> The file you are trying to upload must be $size or smaller");
}
}
//checks if file exists
if (file_exists("$abpath/$img_name")) {
chmod ("$abpath/$img_name", 0666);
unlink("$abpath/$img_name");
}
@copy("$img", "$abpath/$img_name") or die("<b>Error:</b> Directory Not Created or chmod correctly");
echo"Image Successfully Uploaded ($abpath/$img_name)<br>";
}
}
It is saying Unlink (operation not permitted) and accusing me of not chmoding the directory properly (the dir is chmod 777 so should be fine)
I put the file chmod in to see if that would let me delete it, but there is no damn file to delete in any case, the directory is empty!
Is it something to do with permissions or something, im very confused as to why it's not working any more......