Jump to content

unlink()


kev wood

Recommended Posts

does any body no where i am going wrong with this code i keep getting an error message back saying Warning: unlink(): No such file or directory in /home/acmeart/public_html/mercury/upload.php

 

i am using a variable with the path to the image stored in to it and using this in the unlink.  can this be done.

 

my code on this looks like this.

 

unlink($broad1name2);
//we will give an unique name, for example the time in unix time format
$image_name=image1.'.'.$extension;
//the new name will be containing the full path where will be stored (images folder)
$broad1name="image/".$image_name;
$broad1name2="image/thumbs/thumb_".$image_name;
$copied = copy($_FILES['broad1_image']['tmp_name'], $broad1name);
$copied = copy($_FILES['broad1_image']['tmp_name'], $broad1name2);
   $sql="INSERT INTO images_broad (broad1) VALUES ('$broad1name2')";
   $query = mysql_query($sql);
//we verify if the image has been uploaded, and print error instead
if (!$copied) {
echo '<h1>Copy unsuccessfull!</h1>';
$errors=1;

 

 

Link to comment
https://forums.phpfreaks.com/topic/102723-unlink/
Share on other sites

  • 2 weeks later...

the files have already been uploaded on a different page i have checked on the server i have code now which is working fine i will post it up here so everyone can see.

 

$fileToRemove2 = 'www.acmeart.co.uk/mercury/image/thumbs/thumb_image2.'.'.$extension';
$exts = array('jpg', 'png', 'gif', 'jpeg');
foreach($exts as $ext) {

   if (file_exists($fileToRemove2.'.'.$ext)) 
     {
        @chmod(0777, $fileToRemove2.'.'.$ext);
     }
     @unlink($fileToRemove2);
   }

Link to comment
https://forums.phpfreaks.com/topic/102723-unlink/#findComment-534219
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.