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 6656059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:35:47+00:00 2026-05-26T01:35:47+00:00

I done delete image url from database with following code, but is not delete

  • 0

I done delete image url from database with following code, but is not delete file image from upload path, how can delete file from upload path with url it in database (both together)?

This php is just for delete url from database:

$delete = $this -> input -> post('checked');
foreach($delete as $val) {
    $this - > db - > delete($this - > _table, array('id' = > $val));
}

Update:

I have error in use of following code.

$id = '166';
$query = $this - > db - > get_where('hotel_image', array('id' = > $id));
if ($query - > num_rows() > 0) {
    $res = $query - > row();
    unlink(base_url(uploads/$res - > images));//This is line 161
}
$this - > db - > delete('hotel_image', array('id' = > $id));

Error:(my images are in this pach: http://example.com/uploads/)

A PHP Error was encountered
Severity: Notice
Message: Use of
undefined constant uploads – assumed ‘uploads’
Filename: user/dence.php
Line Number: 161

A PHP Error was encountered
Severity: Warning
Message:
unlink() [function.unlink]: http does not allow unlinking
Filename: user/dence.php
Line Number: 161

  • 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-26T01:35:48+00:00Added an answer on May 26, 2026 at 1:35 am

    You need to use unlink() to delete a file from disk, just pass the filename as parameter.

    bool unlink ( string $filename [, resource $context ] )

    Deletes filename. Similar to the Unix C unlink() function. A E_WARNING
    level error will be generated on failure.

    Something like (this is simplified code. You might want to check the path from DB is complete or else add the rest.):

    $delete = $this -> input -> post('checked');
    foreach($delete as $val) {
        $this->db->select('images')->from($this->_table)->where('id',$val);
        $query = $this->db->get();
        if($query->num_rows() > 0)
        {
          $res = $query->row();
          $file = './uploads/'.$res - > images));
          // echo $file;  #check if this is the correct path!
          @unlink($file);
        }
        //now query to delete
        $this -> db -> delete($this - > _table, array('id' = > $val));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which takes an improperly saved Image from the database
I am Unable To Delete Image File From My Server Path It Gaves Error
The following code should rotate an image 90 degrees, but it isn't working. Instead,
I want to partially update page when i upload or delete the image. What
I'm trying to write the following spec using Specs2 but can't seem to get
In the boost::shared_ptr destructor, this is done: if(--*pn == 0) { boost::checked_delete(px); delete pn;
I have done Java and JSP programming in the past, but I am new
I've only done a bit of Flex development thus far, but I've preferred the
I've done this before in C++ by including sqlite.h but is there a similarly
Can this be done by setting a property? I'd prefer that approach then to

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.