Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6047287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:20:04+00:00 2026-05-23T07:20:04+00:00

What you see below is a part of my script. The problem is that

  • 0

What you see below is a part of my script.

The problem is that I need only the re-sized thumb image and not the original file. The image won’t re-size if it is not uploaded, therefore the process should look like this:

  • -> creates a folder
  • -> uploads original image
  • -> resize and stores the thumb
  • -> deletes the original file.

Now this last part (deletion) does not work. I get this error:

PHP Warning: unlink($target_file) [function.unlink]: No such file or directory in /path/file.php on line X

It does not find it!

if (isset($_REQUEST['Submit'])) {

    mkdir($dirloc, 0755, true); 
    $i1=$_FILES['image']['name']; 
    $nw1="$dirloc/".$i1; 

    if ($i1) {
        $copy1 = copy($_FILES['image']['tmp_name'], $nw1);
    }

    $fileName = $_FILES["image"]["name"];
    $kaboom = explode(".", $fileName);
    $fileExt = end($kaboom);
    function ak_img_resize($target, $newcopy, $w, $h, $ext) {
        list($w_orig, $h_orig) = getimagesize($target);
        $scale_ratio = $w_orig / $h_orig;
        if (($w / $h) > $scale_ratio) {
            $w = $h * $scale_ratio;
        } else {
            $h = $w / $scale_ratio;
        }
        $img = "";
        $ext = strtolower($ext);
        if ($ext == "gif"){
            $img = imagecreatefromgif($target);
        } else if($ext =="png") {
            $img = imagecreatefrompng($target);
        } else {
            $img = imagecreatefromjpeg($target);
        }
        $tci = imagecreatetruecolor($w, $h);
        imagecopyresampled($tci, $img, 0, 0, 0, 0, $w, $h, $w_orig, $h_orig);
        imagejpeg($tci, $newcopy, 80);
    }
    $target_file = "$dirloc/$fileName";

    $resized_file = "$dirloc/thumb.$fileExt";
    $wmax = 150;
    $hmax = 150;
    ak_img_resize($target_file, $resized_file, $wmax, $hmax, $fileExt);
    $xxx = $resized_file;
    $delete_target_file = unlink('$target_file');    

    $sql = "INSERT INTO $db_table(path,code,timecode,catg,description,title) values 
            ('$xxx','".mysql_real_escape_string(stripslashes($_REQUEST['code']))."',
            '".mysql_real_escape_string(stripslashes($times))."',
            '".mysql_real_escape_string(stripslashes($_REQUEST['catg']))."',
            '".mysql_real_escape_string(stripslashes($_REQUEST['area2']))."',
            '".mysql_real_escape_string(stripslashes($_REQUEST['fbox']))."')";

    if($result = mysql_query($sql ,$db)) {
        $codes = $_REQUEST['code'];
        $linkto = "?v=$codes";
        echo "<script>window.location = '$linkto'</script>";
    } else { 
        echo "ERROR: ".mysql_error();
    }
} else {
    // Here comes the form 
}

Could someone explain why it doesn’t delete it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:20:05+00:00Added an answer on May 23, 2026 at 7:20 am

    use double quotes or do not use any quote at all.

    unlink("$target_file"); 
    

    or

    unlink($target_file); 
    

    Variable surrounded with single quote are not parsed you needs to surround them with double quotes or do not use quotes at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very large file that looks like this (see below). I have
See the excerpt below taken from a PL/SQL tutorial. The part I have an
I have the below code that does not seem to work at all :(
I have a pagination script which I have posted below, the problem is I
I have a bash script that I am run to check to see if
Below you see a part of the server-side code of the twich.me node.js chat:
i'm trying to generate permutations from a part of a vector. See below. vector<int>
Clarification This is part of a script that checks if a user has changed
In the script below I am calling a batch file to break mirroring between
As you can see below, in the constructor I'm instantiating a validation object so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.