Jump to content

Mor0ninc

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Mor0ninc's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I GOT IT! I declared my $dir variable outside the IF statement. and on the "action" of my form I added the unlink statement. That worked but then I figured I really don't need the variables for my directory or file, so on my form I just used the variable for the query that was already created. [code]<form id="deleteConfirm_form" name="deleteConfirm_form" method="post" action="<?php unlink("uploads/" . $row_items['image']) ?>">[/code]
  2. I just tried getting straight to the point [code]if ((isset($_POST['hiddenID'])) && ($_POST['hiddenID'] != "")) {   //$dir = "uploads";   //$file = $row_items['image'];   //$remove = $dir . "/" . $row_items['image'];   unlink("uploads/" . $row_items['image']) or die("Image could not be deleted");[/code] but I can do [code]<?php echo "uploads/" . $row_items['image']; ?>[/code] and I get "uploads/test.jpg" if I change my code to this, then it will work [code]if ((isset($_POST['hiddenID'])) && ($_POST['hiddenID'] != "")) {   //$dir = "uploads";   //$file = $row_items['image'];   //$remove = $dir . "/" . $row_items['image'];   unlink("uploads/test.jpg") or die("Image could not be deleted");[/code] but why can't i get the variables to work in the unlink()?
  3. Thanks for the response, I tried doing that to a few things that I thought may cause the issue. You are right though, it is not getting the file name, and I am not really sure why not. I even looked up some examples and found some laid out pretty much like mine. I did an echo on $row_items['image'] and it retrieves the image name from the database, but when I do an echo on $file it comes back blank. I tried taking the $file out of the picture and still nothing. [code]if ((isset($_POST['hiddenID'])) && ($_POST['hiddenID'] != "")) {   $dir = "uploads";   //$file = $row_items['image'];   $remove = $dir . "/" . $row_items['image'];   unlink($remove) or die("Image could not be deleted");[/code] I don't get it.
  4. I am setting up a place for myself to post personal items for sale. I can post a name, description, price, and a picture. The problem I am having is that I am able to upload the photo and update my database with it's path, but I cannot delete the file from my server when I delete the record from my database. I am using the unlink command. [code] if ((isset($_POST['hiddenID'])) && ($_POST['hiddenID'] != "")) {   $dir = "uploads";   $file = $row_items['image'];   $remove = $dir . "/" . $file;   unlink($remove) or die("Image could not be deleted"); [/code] That is the section that deals with the deletion of the file, I added the " or die("image could not be deleted");" so that I wouldn't have to re-create my test item everytime the file deletion failed. If I remove the "or die..." then everything works ok except it leaves the image file on the server, but still removes it's path from the database. What i don't understand is that if I change "$file" to equal the actual image file name it works perfectly fine. That tells me that it is not the rights to the folder. I wouldn't think anything in my php.ini file is wrong seeing as it works when I type the filename in for "$file". PHP 5.1.4 IIS 6.0 MySQL 5.0.18
×
×
  • 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.