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);

?>

 

 

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))

 

Archived

This topic is now archived and is closed to further replies.

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