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

  • Home
  • SEARCH
  • 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 7768989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:03:36+00:00 2026-06-01T16:03:36+00:00

I have a php file which has the following path Shubhmangalam/admin/welcome_image_edition/delete_image.php and an image

  • 0

I have a php file which has the following path

Shubhmangalam/admin/welcome_image_edition/delete_image.php

and an image file with the following path

Shubhmangalam/welcome_images/image_1.jpg

I want to delete the image_1.jpg file which I know can be done by using unlink() method..
but the prob is that the parent folder of the .php file and .jpg file is different, and so is their level of file-system…and I cant find the proper way to get the path to delete the image_1.jpg file.

Now the code on the delete_image.php is accordingly

<?php
$image=$_REQUEST['image'];
if(unlink("./../welcome_images/".$image))
   echo "Successfully Deleted";
else 
   echo "Wrong";
?>   

Now the above is server-scripting code, I want to delete the image by getting appropriate path.. I dont want the actual path, but the path from the project folder that is Shubhmangalam

thanks in advance

  • 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-06-01T16:03:37+00:00Added an answer on June 1, 2026 at 4:03 pm

    Be VERY careful with this type of code. You’re not filtering the $_REQUEST value AT ALL, which allows a malicious user to specify ANY file on your server, e.g:

    http://example.com/delete_image.php?image=../../../../../../../../../etc/passwd
    

    You can fix your pathing problem by using an absolute path:

    unlink('/path/leading/to/your/welcome_images/' . $image);
    

    which relives you of the burden of having to figure out the appropriate relative path.

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

Sidebar

Related Questions

I have a php file, say include.php which has the following contents: <?php $myVar
I have a main.php file which has the following three included php files: <!--TAB
I have a PHP file which has the following text: <div class=small_italic>This is what
I have a php file which has a require_once Statement (?) this file is
I have an index.php file which has to process many different file types. How
I have 2 files namely: uploading.php emaillinks.php both include a file inc.php which has
I have a php file which I will be using as exclusively as an
I have a PHP file which will return something like <div id=title>Add Us On
i have one php file which process adding of record in Database fro array.
I have a php file that contains a form (which contains 2 input boxes

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.