Jump to content

Delete files from directory


emediastudios

Recommended Posts

now all i got to do is sort out the filedelete.php

I was given this code below but nothing, justs timesout

 

<?php
$filename = 'gcproperty/images'.$_GET['file'];
$file = $_GET['file'];

// set up basic connection
$ftp_server = "localhost";
$ftp_user_name = "root";
$ftp_user_pass = "5050888202";
$conn_id = ftp_connect($ftp_server);


// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// try to delete $file
if (ftp_delete($conn_id, $filename)) {
echo "<p><center>The file $filen was deleted successfully.<br />";
echo "<center><a href=admin.php>Back</a>";
} else {
echo "<p><center>Could not delete $file.<br />";
echo "<center><a href=admin.php>Back</a>";
}

// close the connection
ftp_close($conn_id);

?>

 

 

Link to comment
Share on other sites

You should try and do it yourslef, then you will understand what is going on. What you need to do is add a delete button on the page that displays the image. When this button is clicked then run a delete script. In this script you will need;

 

1) Sql Delete function, to delete the file out of the database

2) then if the sql delete works then do the unlink(delete) from the directory by using if (@unlink("/images/" .$file))

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.