SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2001
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unlink() Assistance Please

    I have a form where data and images can be uploaded. Everything works fine but when I delete the record I get an unlink() error if there was no file uploaded with the record becuase there's no file found to delete.
    If there are 2 images uploaded then there are no errors cos unlink is happy its done its job
    How can I stop the error? Maybe an else or if? I dunno how to do it tho
    Here's my little bit of unlink code:

    $imagedir = ("../../images");
    $imagefile = ($row_DelRecord['Img1']);
    $imagefile2 = ($row_DelRecord['Img2']);
    unlink($imagedir . '/' . $imagefile);
    unlink($imagedir . '/' . $imagefile2);
    All I want to do is stop the error if there's only 1 file found or if there's none uploaded.
    Thanks in advance

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $imagedir = ("../../images" );
    $imagefile = ($row_DelRecord['Img1']);
    $imagefile2 = ($row_DelRecord['Img2']);
    if(
    file_exists($imagedir.'/'.$imagefile)){
        
    unlink($imagedir '/' $imagefile);
    }
    if(
    file_exists($imagedir.'/'.$imagefile2)){
        
    unlink($imagedir '/' $imagefile2);


  3. #3
    SitePoint Member
    Join Date
    Dec 2001
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •