Re: Re: deleting a file in another directory
| From: | mailing | Date: | Thu, 22 May 2003 10:30:33 +0000 |
| Subject: | Re: Re: deleting a file in another directory | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148527@lists.php.net to get a copy of this message | ||
Sure...
The script (del_appro.php) is called from a link as:
del_appro.php?imageid=12 which is in the sites root directory. The mysql
data is getting deleted if I remove the unlink part that is causing me
problems. The images that it need to delete are in /appro_image and are
named $filename.
<?
session_start();
include_once("admin/config/header.inc.php");
include_once("admin/inc.php");
include_once("member_header.php");
check_valid_user();
if ($valid_user !== $pageowner)
{echo "<BR><BR><BR><CENTER><H2>You are not authorised to use this
page!<BR></h2></center>";
exit;}else{
{
$sql ="select * from approval where imageid = $imageid";
$result = @mysql_query($sql) or die(mysql_error());
$num = @mysql_num_rows($result);
//while ($row =mysql_fetch_array($result)){
$imageid=$row['imageid'];
$imagename = $row['imagename'];
$filename = $row['new_name'];
$verdict = $row['verdict'];
$approved_by = $row['approved_by'];
$comment = $row['comment'];
$datestamp = $row['datestamp'];
$imageowner=$row['userid'];
//DELETE THE IMAGE FILE FROM THE APPRO_IMAGE FOLDER
unlink("./appro_image/$filename");
mysql_select_db( "release" ) or die( "cannot select database
'release'" );
$sql = "delete from approval where imageid = '$imageid' ";
$result = @mysql_query($sql) or die(mysql_error());
echo "<center><h2>Image and data has been
deleted</H2></center><br><br>
<a href='appro_manage.php'>Return to Approval Management Form</a>
";
}
}
?>
Dont be too hard on the standard of my scripting.... I am learning!
Cheers
James
> From: "Craig" <craig@deconstructor.net>
> Date: Thu, 22 May 2003 11:03:43 +0100
> To: php-general@lists.php.net
> Subject: [PHP] Re: deleting a file in another directory
>
> Can we see the full script??
>
> "Mailing" <mailing@jduncan.co.uk> wrote in message
> news:BAF259C4.555B%mailing@jduncan.co.uk...
>> Hi
>> I am trying to write a script to delete an image file in a directory under
>> the script directory but I get this error :
>>
>> Warning: Unlink failed (Is a directory) in (my directory path to script)
> on
>> line 48
>>
>>
>> Line 48: unlink("./appro_image/$filename");
>>
>> Read manual / searched google etc
>> Any advice greatly appreciated.
>> James
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>