Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Unlink (delete Files) With Asterix's?


is it possible to delete a file and use an asterix? (or any wildcard)
ie, I tried  @unlink(Username_CV_."*"); and @unlink(Username_CV_.*); to no success.

the ending is a date, so it could be Username_CV_june27_2007 or aug31 or whatever, and obviously I don't want to delete ALL the files from other users as well...

I guess I could store the file name in a table, but it would be nicer to not need that to simply delete simple a file..




View Complete Forum Thread with Replies

Related Forum Messages:
Deleting Files Using Unlink [function.unlink]: Permission Denied
I have a record in the db and a picture file name recorded with that record. I am writing a deletion routine which checks that file name and is supposed to delete it using unlink.

Although it reports the correct directory and file name, I received the following:

Warning: unlink(/home/pab/html/pics/test.jpg) [function.unlink]: Permission denied

I checked my permissions and the file is set at my user name and 666.

Does anyone know why this won't work or maybe another way to delete the file?

View Replies !
Trying To Delete A File Using Unlink
i am trying to delete a file using the unlink function but it just is not working. i just get the Could not delete message. Is there anyway to find out exactly what is wrong? I've tried the exact path which is C:/domain/wwwroot/temp/0000000.txt but it just does not delete. Also i dont think it can be related to permissions because the 0000000.txt was created automatically by a script. The code i used is as follows:

<?
$delete = unlink("C:/domain/wwwroot/temp/0000000.txt");

if($delete)
{
echo "Succesfully Deleted";
}
else
{
echo "Could not Delete";
}
?>

View Replies !
PHP Unlink() & Mysql Delete
Im trying to delete a file, then delete the row in my table that holds the info for this file. I tried the code below and got this error:

Parse error: parse error, unexpected T_STRING in /nfs/cust/4/97/13/731794/web/Admin/backup/PXS_DeleteBackup.php on line 34


Here is my code:

View Replies !
File Delete / Unlink
i have made scirpt that list all the files in a dir so you can delete them but it wont delete i get the page as normal but when you select one and click delete it don't work! Code:

View Replies !
Unlink Command In Order To Delete The Images
I am developing a website that requires to upload, update and delete images. I have successfully managed to upload and update the required pictures but i have some problems when i try to delete the images. Actually i am using the unlink command in order to delete the images but the image is not deleted form the server. Because my client needs to upload images frequently, we cannot afford keeping the old images on the server. How i can actually delete the images and remove them from the server?

View Replies !
Delete Complete Folders With Unlink Or Rmdir
i have a directory with structure like

project
- images
- include
- classes
- deletefolder.php

i want to delete three folders from project directory which is my main site folder. the page that will take action also resides in project directory. i was using command like
PHP Code:

View Replies !
Unlink All .png Files
this is another problem I'm having with unlink. This is the error i get:

Warning: Invalid argument supplied for foreach() in d:ServerApachehtdocs rackerincludesdelete.php on line 17

On line 17 and onwards, i got just this: PHP Code:

foreach (glob("*.png") as $filename) {
unlink("$tempimgpath/$filename");
}

in config.php, which is included in delete.php by the way
$tempimgpath = "d:/Server/Apache/htdocs/tracker/images/temp";
and I've also tried with directory, like
$_tempimagedir = "images/temp";

but everytime I get that error, any idea what I'm doing wrong?

View Replies !
Unlink Files That Are Checked
Has anyone written a script where you can view files in a directory and then delete them? Next to each file name is a check box. If you check the check box and click a delete button, the file will be deleted from the directory it resides in.

This script allows me to upload files to the upload folder on my webserver. I can also view all files in the upload folder. The only thing I can't do is put a check next to the file I want to delete and click the delete button to delete the file from the upload directory. Any ideas????

Thanks,

Jamie


<html>
<head>
<title>File Management</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">

<?
//check for file upload
if(isset($uploadedfile))
{
$directory = "upload";
$path1= dirname($PATH_TRANSLATED)."/$directory/";
// assign our path in a form PHP for Windows understands
$dest = $path1.$uploadedfile_name;

set_time_limit(120);

// Free the memory allocated
Copy("$uploadedfile",$dest) ;

// Destroy the file now we've copied it

unlink($uploadedfile);
}
?>

<p><b><font size="6" color="#400080">Georgia Power - Plant Bowen File Upload and
Download</font></b></p>
<p>Click on the file you would like to download:</p>


<?
// Here I print out the list of files from the upload directory, with a check box next to
// each file. I put a check in the checkbox if I want to delete a file.

$file_array = array();

$dir = "upload";
$sPath= dirname($PATH_TRANSLATED)."/$dir/";

function GetDirArray($sPath)
{
global $file_array;

$handle=opendir($sPath);

while (false!==($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
print $file_array[]= $file;
print "<INPUT TYPE=checkbox NAME="checkbox".$i."" value=checked>";
print "<br>";
}
}

closedir($handle);
sort($file_array);
}

// This code is supposed to be deleting files that are checked........
if(isset($checkbox))
{

unlink($file);
}

GetDirArray($sPath);
?>

//This is the button and browse button to upload files to the upload folder.
<p>&nbsp;</p>
<FORM ENCTYPE="multipart/form-data" ACTION="<? $PHP_SELF ?>" METHOD="POST">
<p>
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="100000">
Upload This File:
<INPUT NAME="uploadedfile" TYPE="file">
<INPUT TYPE="submit" VALUE="Upload">
</p>
</FORM>

//Here is the delete button to delete files who's checkbox is checked.
<FORM ENCTYPE="multipart/form-data" ACTION="<? $PHP_SELF ?>" METHOD="POST">
<input type="submit" name="delete" value="delete">
</FORM>
</body>
</html>

View Replies !
Deleting Files Using Unlink()
I have been searching the forums for examples of using unlink() and I thought I understood it, but my code is not working. I have a form where the user can upload an image. The image is stored in a directory on my server and the path to that file is stored in a database.

I have have another form that allows an admin to delete that row from the database, but I also want the actual image file deleted too. I don't recieve any errors, but the rows get deleted from the database and images do not get deleted. I am using PHP5, MySQL and PEAR. Does anyone have any thoughts on why this is not working? Here is my code: PHP Code:

if($_SERVER['REQUEST_METHOD']=='POST') {
    if ($_POST['yes_no'] == 'yes') {
        $isbn = $_POST['isbn'];
        $sql_select = "SELECT image FROM lounge WHERE isbn = $isbn";
        $rows = $db->getRow($sql_select);
        $uploaddir = "uploads/";
        $filename = $rows[image];
        $image = $uploaddir.$filename;
        unlink($image);
        
        $sql_delete = "DELETE FROM lounge WHERE isbn = $isbn";
        $db->query($sql_delete);
        print "<script>window.location='water_music_retrieve_testing.php'</script>";
    } else {
        print "Record not deleted";
        print "<script>window.location='water_music_retrieve_testing.php'</script>";
    }
    }

View Replies !
Deleted Files Using UNLINK
I specified the wrong path using the UNLINK command and deleted all my code. No backup and can't undelete using a couple of undelete programs.

View Replies !
Unlink() Deleting Files
I looked up the definition for unlink() and of course it deletes files. But im a little bit confused. you can put the file name into the parameter but how does it know what directory to find the file so it can delete it.

View Replies !
Unlink() Files From A Directory
I am trying to unlink() files from a directory, but its not picking up the $file. It gives me a permission denied error and shows just the directory that it trying to be deleted. It should be "FullPathToFolder/$file", but it is only trying to unlink "FullPathToFolder".

<?
$dirpath = "FullPathToFolder";
if ($submit_edit)
{
unlink("$dirpath/$file");
}
$dh = opendir($dirpath);
while (false !== ($file = readdir($dh)))
{
if (!is_dir("$dirpath/$file"))
{
echo "<form action='$PHP_SELF' method='post' enctype='multipart/form-data'>";
echo "<input value='$file'>";
echo "<input type='submit' name='submit_edit' value='Submit'>";
echo "</form>";


View Replies !
Warning: Unlink() [function.unlink]: Permission Denied In C:Program
i'm getting this error when i try to upload an image-
Warning: unlink() [function.unlink]: Permission denied in C:Program Filesxampphtdocsepeopleupim.php on line 79

Does this mean i need to change the directory permission to allow php to move/copy an image into the directory?  if so, can i right-click on directory folder (i use windows xp) and go into properties and change the permissions in there? If so, what do i change it to? Code:

View Replies !
Delete Files - Check All Files In /home/radar/kabc*.png
Trying to figure out a code to do something that is probably simple, but I'm not able to find anything to combine to make it happen. Here is what i'd like to accomplish. Check all files in /home/radar/kabc*.png --- if those files are older than x hours, delete them. After deleting those files, I'd like to copy new "placefiles" in the place of the image, basically, copy test.png to kabc101.png (example filename). I'd like to not loop this process if the file size is equal to 123456 bytes exactly, and have the owner of those files a certain user.

What this is, is a radar software that I use to upload to my personal website, so if there's no weather going on, I don't use the radar software, and it's not updating the radar on the web, so, after so many hours of the software not uploading anything new, i'd like to find a way to have these placefiles put in place. Once I start my software again, it'll overwrite those files automatically. Does this seem like it's possible? Is it an easy task?

View Replies !
Warning: Unlink() [function.unlink]:
i tried to use the unlink function to delete an image but i get an error message whenever i try to do it.

Warning: unlink() [function.unlink]: http does not allow unlinking in /home/ppages/public_html/doc/admincontrol/models/forhire/edit.php on line 15

anyone have any ideas?

View Replies !
Can't Delete My Own Files
i'm trying to create some directories on my server via a script, and copy standard files into them. it all goes smoothly, but i cannot delete the files when i log into my webserver's FTP. i'm guessing wrong chmod code, but its so long since i used unix. here is the code: Quote:

$h_name = "test";

copy("$_SERVER[DOCUMENT_ROOT]/photos/EXAMPLE_HOTEL.php","$_SERVER[DOCUMENT_ROOT]/photos/$h_name.php");
copy("$_SERVER[DOCUMENT_ROOT]/photos/EXAMPLE_HOTEL_window.php","$_SERVER[DOCUMENT_ROOT]/photos/{$h_name}_window.php");

mkdir("$_SERVER[DOCUMENT_ROOT]/photos/$h_name", 0777);

copy("$_SERVER[DOCUMENT_ROOT]/photos/EXAMPLE_index.html","$_SERVER[DOCUMENT_ROOT]/photos/$h_name/index.html");

View Replies !
Delete Files
I have a part of my site that will allow a user to create a group. When they create the group then can assign a picture to that group. I store the filename in the db and then I create create a folder for them on my web server and upload the image to there.

My question is if they choose to update their picture I want to delete the old file and then upload the new file that they choose to be their picture. How would I do this.

I know that I would have to run a query to get the old file name before updating it in the db but after I get that I'm not sure how to delete it from the web server.

I also know how to upload the file so that isn't a problem either, it's just the step before that of deleting it from the server.

View Replies !
How To Delete All Files Beginning With ... ?
I'm using PHP 4. I would like to delete all files in my directory
/mydir that match the regular expression

/mydir/temp*

What is the shortest way in which I can do this?

View Replies !
Delete Record And Files
I have a code that uploads images along with some info into a directory and database, this all works fine. I can delete the record but the images relevent to that record continue to exsist in my images directory. How would i set up a php code to delete a file in ../images when the record of its name is stored in a column in my database. Here is my delete record code:

View Replies !
Delete Certain Files From A Directory...
Is there any way to make a function that deletes all files of a certain EXTENSION? let's say ".txt" files... how could you use the unlink command to delete all files that have the extension ".txt"?? I know how to recursively unlink all files in a directory, but I can't seem to figure out how to delete all files with a certain extension...

View Replies !
Script To Delete Files
I have a website that is hosting mp3's. They are all named and the path is stored in mysql such as 1234.mp3. I am wanting to do a little cleanup and write a script that will check every mp3 file on the site, and then verify through a loop that the song exists in the DB. If not, I want to delete it. I know how to use unlink but am not sure how to setup a loop that will get the filename of every mp3 within a certain directory.

View Replies !
Delete Files Every X Hours
I need a simple snippet that'd point me in the right direction on how to delete all the files inside a folder every __ hours.

View Replies !
Scheduling To Delete Files
in my web site i have an option of building html pages dynamically but,by this i can't save the disk space,i want to delete the files in a schedule dynamically .

View Replies !
Delete Files That Contain Quotes
I created a file upload form. After uploading file that had a quotation mark in it, PHP escaped the quotation mark and now the file name has an illegal character in it. It seems that move_uploaded_file() allowed the file to have the forward slash. I've correct the escaping of quotes issue by using stripslashes on the 2nd parameter.

Now however any files already uploaded that have the illegal character can't seem to be deleted. I can't download them either through ftp. I am using an apache server hosted through site flip. Is there anything I can do to delete these files or am I stuck with them on the web host? Things I've tried. Renaming with PHP, renaming with FTP. None of those seem to work. Is there something I can install that will force a file rename even if it has invalid characters in it?

View Replies !
Delete Files That Are 4 Days Old
i have a code that deletes files that are certain days old, but i dont know exactly how old and i wanted to increase it to delete files that are 4 days old.

unlink $filename if $current - (stat $filename) [10] > 1 * 60 * 60 * 24;

View Replies !
Delete Files From A Directory
I am trying to made a script that will show all the files in a Directory….. Also I want to add the option to delete the files from the directory.

I can view the files on the directory the problem is when I add this line that add the option to delete the files in the directory
LINE--->27 echo "<a href="browserdir2.php/?k='.$link.'&ko=1">'.$file.'</a><br>";

The error message that I get is :

Parse error: syntax error, unexpected T_STRING, expecting ',' or '' in c:diphpwebrootrowserdir2.php on line 27

Code:

View Replies !
Delete Files Recursive
I have a problem and don't know where to begin. My default folder is export. This is where all the files comes in, with all kinds of extentions, but with also a lot of sub-folders. I have a text file with all the extentions, I like to delete from the export folder and all the subfolders. 1 extention at 1 row. Some of these extentions are 'exotic' like exe--fileslack ,so not only the common 3 characters extentions. Is there a way to delete those not wanted files automaticly, without harming the other extentions.

View Replies !
Delete All Files In A Directory
I delete all files in a directory if I don't know the names of the files? I would think I would want to do some kind of file_delete() but don't know if there's a way to have it delete all files that it finds in a certain directory.

View Replies !
Delete Temp Files
I have few GD galleries which work fine. The only problem are the temp files. Before processing pictures, they are copy in my temp directory (as a preview). Is there a way to have a script which will delete temp files which are note dated from today's date. It seems that $_files[date] do not exist.

View Replies !
How To Delete Files Uploaded And Now Owned By PHP
Within homes/ PHP creates a directory, it's an integer such as homes/999 or homes/345. Within that new directory, PHP uploads some graphics, .gif or .jpg.

The problem is, that directory and all those graphics are now "owned" by PHP, usually running as nobody or www. I can't delete them or copy them.

I've tried running a chown() within PHP to make myself the owner, but I get "operation not allowed".

The only solution I've found so far is to set umask(0), so that the directory and graphics have 777 permissions. I don't think that's very safe, though, is it?

Does anyone have any suggestions. I want to be able to delete or copy the files like they are mine, but only me or my group. I'm not running the server myself, but those who are seem willing to work with me.

View Replies !
Delete Files On Server Using Browser
I have several php files in a folder. I would like to have the possibility of deleting these files using my browser, rather than having to log onto the server and do that.

Reason? I am dealing with a slightly slippery client, in case he changes the password after i have put the entire site on it, i would like to be able to delete my files, in case i get stiffed on the payment.

Would appreciate any pseudo code/code on getting this done, if possible.

View Replies !
Delete A Directory And All Its Files And Sub-directories?
Does anyone know of, or have code that will delete a php directory and
all its sub directories and files. "unlink" and "rmdir" don't do this.
I'd prefer not to use "exec" with a system call but if that's the only
way, so be it.

View Replies !
Delete Files From A Dir Older Than A Week
The below should delete files from a dir older than a week. I set the $dtime to 0 to test the script but it deletes nothing. What is wrong? Code:

View Replies !
Recursive Delete All Files/folders
I want to delete all file and folder recursivly under php code, can
anyone give me commend for this.

View Replies !
How To Delete All Sessions (session Files)?
What line(s) of PHP code can I use to delete ALL existing session files? I tried:

$_SESSION = array();
session_destroy();

......but those two lines appear to only delete the session file that was created for the current session.

View Replies !
Delete Files On Win2k - Permission Denied
I'm trying to delete local files within a php-script running on win2k (I'm loggend in as administrator, the script is not meant to run in a web-environment but only from commandline).

the problem is I get a "permission denied" when I try to delete the file with unlink($file) or try to move it with ($oldpath.$file,$newpath.$file). since I'm administrator there shouldn't be problems with win2k's file-permissions, the files I'm trying to delete are full accessible for everyone.
the php manual says that "unlink" probably won't work on windows but doesn't say how to delete files then?

View Replies !
Delete Records And Files In 1 Statement At Same Time?
How can i delete records and files in 1 statement at same time?

View Replies !
Delete Files From Server Based On Filename...
I need to open a folder on my server, then look at the files in the folder.... then if I find a file that meets a criteria - i want to delete it. for example, I have a file list such as

1_hello.jpg
1_boo.gif
2_raaaa.gif
4_mad.jpg
etc etc

The numbers at the beginning indicate the userid and an image they have uploaded... I need to open the folder, tell the script that anything starting with a "1_" should be deleted.

View Replies !
Check For Other Files With The Same Name But With A Differrent Extension And Delete Them
I'm using this to upload a file and then rename it to a format like 4-5.jpg: I would like to check for other files with the same name but with a differrent extension and delete them. How would i do that? PHP Code:

$tmp_name = $_FILES["pic"]["tmp_name"][$key];
      $name = $_FILES["pic"]["name"][$key];
      move_uploaded_file($tmp_name, "$archive_dir/$name");
      $ext = substr_replace($_FILES["pic"]["name"][$key],"",0,strpos ($_FILES["pic"]["name"][$key],"."));

      $new_fn[$key] = $item_no."-".$key.$ext;
      rename("$archive_dir/$name", "$archive_dir/$new_fn[$key]");

View Replies !
Define Files For View/edit/delete
I am working on this little file manager project, I know, there's lots out there. However, I couldn't find one that paged the results that didn't use a DB. Now that I have it set up (works great),

I'm not sure how to define the files and not mess up the paging - so that if it's a folder you can open it and work with the files, a photo you can view or delete it and if it's a .txt, .php. etc. you can edit it. Code:

View Replies !
How Do Delete All Of The User's Temporary Internet Files?
I have a site with a flash object. IE7 keep caching the photos of the flash. i tried clearstatcache() but it didn't.

View Replies !
How Can Delete Spaces And Special Chars At Files In Several Directories?
a mp3 file in a directory is named &#350;ebnem Ferah - S&#304;GARA.mp3
but it is nearly 900mb all of this files and nearly 20 directories I have..
do you know a way to rename this files name by easly?

View Replies !
Can't Delete Files On Folders Via Ftp :: Chmod(): Operation Not Permitted
I had some problems with an upload script i was working on. This has resulted in what has been uploaded undeletable. File that havebeen upload have there chmod set to 644. I tried changing this in the delete script but i am getting an error

chmod(): Operation not permitted

So i tried to delete via my ftp prog and get the same problem.

Does anyone know of a solution?

$filepath = "../../media/portfolio/".$clID."/";
if ($handle = opendir($filepath)) {
    while (false !== ($file1 = readdir($handle))) {
        if ($file1 != "." && $file1 != "..") {
        $old = umask(0);
        chmod($filepath.$file1, 0755);
            $del = unlink($filepath.$file1);
            umask($old);
        }
    }    
    closedir($handle);
    $del2 = rmdir("../../media/portfolio/".$clID);
}

View Replies !
PHP/Perl/Unix Virus: Delete Config.php Files Asap
There were some strange requests to my server asking for config.php
file (which I do not have in the requested location).

I did some investigation. Seems to be a virus written in perl,
exploiting a vulnerability in php code.

The requests are like this

216.120.231.252 - - [30/Aug/2006:13:28:03 -0500] "GET /algebra/about/history/config.php?returnpath=http://domates.1gig.biz/spread.txt? HTTP/1.1" 404 561 "-" "libwww-perl/5.805"

File spread.txt contains this:

View Replies !
Delete Record - When The Delete Link Is Clicked The Next Page Is Blank And Nothing Is Deleted.
This is my "delete.php" and this "todo/delete.php?id=64" an example of a link to it generated from the index.php page. When the delete link is clicked the next page is blank and nothing is deleted. What have I done wrong?

<?
include("dbinfo.inc.php");

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$id="delete from todo where id='$id'";
mysql_query($id);

mysql_close();
?>

View Replies !
Mysql Delete - $query = Mysql_query("DELETE
how would i do the following ?

$query = mysql_query("DELETE notes, datestamp, abs_value, ID FROM absence_mgt  WHERE datestamp='$date' AND ID='$vtc_login' ") or die(mysql_error());
im just getting "Unknown table 'notes' in MULTI DELETE" ?

View Replies !
Unlink ( .. )
I need to delete my .jpg files from folder and i'm using: " unlink('files/'.$foto); " as i understand unlink() removes only link but not delete my file ?!

so i need to delete my pictures.jpg files from folder.

View Replies !
Unlink In IIS
I know there are many posts about unlink() not working but ive tried everything and I cant get it to work. This is my command:

$dir has the directory location
$item is the name of the file

unlink($dir.$item);

I can create directories and files fine, but when I come to delete them it wont do it. Unlink always returns false. Im using IIS 6 w/ PHP5 on Windows Server 2003. So I tried the system( del " " ) command and that didnt work either. Im kinda new to IIS so im not sure how to check/set the permissions for the PHP script to delete a file, but do I even need to since I was able to create directories/files already?

View Replies !
Unlink
I am doing a CMS for a client web site but cannot make the unlink work on a windows based server. I have no problem uploading a new file on the server. But when I try to upload a new version of that file with the same name, the move_uploaded_file does not overrite the existing file. I added a check to see if there is a file and delete it but still no luck.

if (is_uploaded_file($HTTP_POST_FILES['fileupload']['tmp_name'])) {
if (is_file($path.$SOQname)) unlink($path.$SOQname);
if (move_uploaded_file($HTTP_POST_FILES['fileupload']['tmp_name'], $path.$SOQname)) {
$message = '<strong>New SOQ uploaded.</strong><br>'
} else {
$message = '<strong>uploaded but not moved to the correct folder.</strong><br>'
};
} else {
$message = '<strong>not uploaded.</strong><br>'
};

View Replies !
Rmdir() And Unlink()?
im making a free file/ftp manager, so it will need to be able to delete files/folders, so, how do i delete files/folders that are inside a folder?

View Replies !
Unlink Permissions
I was just wondering how to assign the appropreate permissions so files can be removed using unlink in MS Vista. I have set the folder to allow full access to all users but this does not seem to be enough.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved