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.





Deleting Files From A Folder...


I have a folder with many pictures in it.
All have the name like: HHMMDDMMYYYY.jpg

H-hour
M-minute
D-day
M-month
Y-year

Now I want to delete all pictures which are older than now()-7days.
How Can I do it? In SQL would be no prob but with file deleting is problem.




View Complete Forum Thread with Replies

Related Forum Messages:
Deleting Files In A Folder Modified Before Certain Date
I use a cache system that requires creation of files in a folder .

Now , what i need to know is how can i delete files created say 3 days ago.

So that the cache remains fresh.

The directory contains around 20,000 files , about 10,000 are generated each day (if they dont exist)

So getting info about the each file after using opendir will cause the server to slow down.

View Replies !
Batch File Deleting And Folder Deleting
I have a folder in my web site where I used php to create and copy in files. but now I can't delete them easily. The only way I know how that is possible is through php. I get an error the following ftp error:

550 th: Permission denied
I had the chmod() set to 0777 on every file and folder. But I still seem to loss control over the files when I try and do things with them through other means.

I think it is because the user I use to access the files via ftp a diffrent user. So I tryed to add a function with chown() for the new files I was posting and uploading. It didn't work on those new files. so it looks like the only thing I can do is use the unlink() function which deletes the files fine.

The only problem is now I have something like 100 sub directories all with files in them. I need to figure out a way to batch delete them. I can't find a script that goes through and finds all file contents including all sub directories and unlink those things.

I found some that will use a for loop to list out the contents of a folder but it is just files. No sub directories. Any body got any ideas on which functions I should use or know where a script is that I can base mine off of.

I am not sure how to approach this since what I tryed with chown and chmod has failed thus far. I currently have no code and am starting from scratch on this batch flushing of my directory.

View Replies !
Deleting Folder
Ive got the following which is meant to delte the may2007 folder if there is nothing inside of it. The only types of file it holds is .doc and .pdf. When I put one of each in there and I delete the .pdf, then this deletes just that and nothing else which is correct because there is still another document (the .doc one) in the folder. However, if I put both in and I delete the .doc one first, then this deletes the whole folder (may2007) when it shouldnt because there is another file in there (the .pdf one).

public function RemoveDownload($iNewsId)
{
$oDownload = $this->GetObject($iNewsId);
if ($oDownload->download)
{
unlink($_SERVER['DOCUMENT_ROOT'].UPLOADS_FOLDER_DOWNLOAD.$oDownload->download_path.'/'.$oDownload->download);
$files = glob($_SERVER['DOCUMENT_ROOT'].UPLOADS_FOLDER_DOWNLOAD.$oDownload->download_path.'/{*.doc, *.pdf, *.DOC, *.PDF}', GLOB_BRACE);//Makes sure that it contains no Image
if(count($files) < 1).........

View Replies !
Deleting Folder And Contents With PHP
Im using this code to delete a folder using my script but it says Directory not empty. What code could i use that will delete the folder, subfolders, and all its contents.

$currentdir = getcwd();
$directory="$currentdir/users/$_COOKIE[username]/albums/$_GET[albumname]";
rmdir($directory);

View Replies !
Deleting Not Empty Folder.
Does any one know how to delete a folder completely (with or with out any content in it).

Situation I am having:

I upload 3 files into a new folder, and rename the folder.
I only see 3 files in it, yes it is correct, but when I see property of the folder, it says I have 4 files! ( I confirm I did not put any hidden files).

Now, the problem comes, when I delete the files. Since I know the exact name of the 3 files, I delete them, but when I want to remove the folder, complaint is the folder is not empty!

View Replies !
Is There Anyway Of Deleteing A Folder And Deleting All Of Its Contents With It?
is there anyway of deleteing a folder and deleting all of its contents with it?
i know that with rm_dir needs to folder to be emptied

View Replies !
Drag Files From One Folder To Another Folder (copy) .. Possible?
Is it possible to write codings PHP or Javascript.. GUI representation
of File handling (ie. Drag files from one folder to another folder (copy)
like our windows).. pls give me some reference codings like this..

View Replies !
How To Detect Number Of Files And Files' Name In A Folder?
I have a server built in window + apche. I am trying to make a photo album, but I don't know what is the code for detecting the number of files in a server folder and the files' name~.

View Replies !
Deleting All Files
Is it possible to delete all files in a folder using unlink() or something similar?

View Replies !
Deleting Files?
Is there a way to delete a file from the server using php? I have a database that stores listings for a real estate agent and if he deletes a listing, I would like to delete any images from the server associated with that listing as well.

View Replies !
Deleting Files By URL?
What can I use to delete files by their url?

For example, the script may want to delete the file

www.domain.com/folder/subfolder/hello.jpg

Assuming this file is on the same server. I need the PHP function to be able to delete this file.

View Replies !
Deleting Files
The plan is to have an alert popup when the user closes a window, this popup should only have one button. When the user presses ok a php script should run on the server and then the window should close.

View Replies !
Deleting All Files With A Certain Prefix
I'm using php 4.4.4. Given a particular directory, I want to delete
all the files that begin with the variable "$prefix". What is the
simplest way to do this?

View Replies !
Deleting All The Files In A Directory
Using PHP 4, what are the shortest amount of lines I can write to
delete all the files in a given directory?

View Replies !
Deleting Files From A Server
As part of a project I want to allow users to save files to a server or delete files from a server. I have the uploader working fine, but i have no idea how i would delete the file from the server.

View Replies !
Attaching/deleting Files
I'm trying to create a tree where you can access files from the tree. The files will NOT be stored in the database, but on the server. I have a web forum eg, where they store the title of the message in a separate table compared with the message which is another table.

How do I store the files and show them on the tree, and how will the system know where to get the files from, if they're not in the database?

View Replies !
Deleting Files Onclick
I have an app that lists out the files on a server.  I have a checkbox at the end of each file.  You can check any number of files.  Then I have a link at the top that says "delete selected files."  Could someone just tell me how to write the code to delete the files in general?  I'm not asking for all the exact code, just the concept.  I assume I will be calling a php or javascript function with the "onclick" method. Code:

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 !
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 !
Deleting Files With A Trigger
I'd like to setup a trigger so that when an item gets deleted, its corresponding files will also get deleted. But I don't want to hard-code (in the trigger function) the directories in which the files reside. I'm not sure how to go about it maybe a custom Postgres variable (if that's possible)? I'm using PHP also (for the trigger function and server-side).

View Replies !
Deleting Files And Folders
I have a Windows environment running Apache, MySQL, and PHP 5.1.2. I can create files and directories with my scripts and delete the files they create. However I cannot delete the directories. Are there certain users (i.e anonymous) that need to have access to the directories in order to delete them.

View Replies !
Creating And Deleting Folders And Files
Hi to Everyone.

After creating trought http a organize number of files and folders. I'm not able to delete them, not even trought an FTP Software like Cute FTP. It replies "Could not delete xxxxx.html".

View Replies !
Error Deleting Uploaded Files
I have a configuration script which creates a directory on the server, directory used for uploading files. Everything works fine (creation of the directory, uploading) but when I try to delete an uploaded file from this directory using total commander as ftp client I get the following error: "550 Delete operation failed".

The used code is something like this:

$cursuri = "../cursuri";
@mkdir($cursuri, 0777);

Note: if I use total commander "chmod 777 cursuri" I don't get any problems.

View Replies !
Zend Studio 3.5.2 Possibly Deleting Files?
At work I'm using Zend Studio 3.5.2 to develop PHP files on my Win2K
desktop machine. I've got Zend Studio setup with a secure FTP (SFTP)
connection to a RedHat Enterprise Linux machine. The files I'm editing
'live' on a Solaris machine and the linux machine mounts them through
NFS. I actually access the files through a symbolic link to the mount
point on the linux box. A little complicated I know, but it does work.

I've been having a random problem lately. Every once in awhile (every
couple of weeks) when I'm in Zend Studio and have a few (not all) php
files open, all the files in the directory where I'm working get
corrupted. They all get turned to a file of nothing but nulls (zeros)
and the files are exactly 512 bytes long. This concerns me because it
seems to only happen to me even though other people work on PHP files
in other directories. The difference is that I'm the only one who uses
Zend Studio regularly. I can't see how that would be a problem since
the connection to the files is through SFTP and is essentially
stateless and connectionless. Has anyone else seen this problem or have
any insight about what might be going on?

View Replies !
Editing And Deleting Flat Text Files
I am working on a php news script that uses text files for it's DB. I have most of it done except for the ability to edit or delete the articles in the DB.

I have only been coding for about a week now so my skills are pretty limited and I have not found any tutorials that cover this issue so if anyone could be kind enough as to show me how this is done I would be most greatful....

View Replies !
Files In A Folder
I need a script that checks for the amount of files in a folder. Is taht possible with PHP.

View Replies !
Files In Each Folder
I'm looking for a script that will display how many files I have in 5 of my folders. for example.

Folder 1 ( 2 files )
Folder 2 ( 0 files )
Folder 3 ( 15 files )

View Replies !
How To Get The Files Names From The Folder Using PHP ..
How to get the files names from the folder using PHP .. is there any
specific command. If yes let me know that..

View Replies !
Paging Of Folder Files
i have a form which has a select button when user clicks it a popup opens which shows all images in abc folder
 
when user clicks on any image the window closes and the name of that image is entered in the text box in parent form, now its working fine uptill here but if user refresh the popup window then it disconnects from parent window so my code that fills the textbox in the parent form and closes the popup window does not work anymore im using it like parent.document.form.texthox.value=abc since popup window is refreshed it does not work as child any more and this code does not work.

View Replies !
Files And Folder Copying
I am trying to write a function to copy an existing folder and folder
structure but am already stuck.

What I want to do is the following:

Copy a default folder (default_folder) and all sub folders within it (down
to a possible 4 levels)
eg default folder
->subfolder1
->subfolder2
->sub subfolder1
->sub sub folder 2

I have a form where the user can enter the name of the new folder and an
option to confirm if they want to copy the files also located within the
default folder.
If the checkbox is not checked then copy just the folder structure only

Can this be acheived in one function or will it be based on 2 where a set of
empty folders are created and where the folders and files are copied over

View Replies !
What Is The Max PDF Files Allowed In A Folder?
Not sure where to put this question? I am building a book archives database with a front-end for some librarians. They want to upload book cover images onto the server (probably Win-NT). There are approximately 80000 records that will have the book cover images stored in a PDF document for each. Can I upload every PDF to the same folder? Is there some kind of limit for a folder?

View Replies !
Opening Files In The Same Folder..
I have a php file (1.php) that needs to open another php file (2.php) and parse it's output. 2.php gets it's data from an xml file and formats it in a pretty screen style. So what I need is something like: $fp = fopen ("2.php?file=file.xml","r"); but that wont work because there is no file called &#392;.php?file=file.xml' so how's it done?

View Replies !
Root Of Folder App Files
While I know putting a app into a folder was chiseled out of fine
scottish granite and carried upto the top of ben nevis by php newbies
many years ago - I dont think a folder is the best way to do it .

The fact a script is in a folder means certain instant problems if you
want to do certain things with .

Assuming a script doesnt have index.php and all the script files have a
filename prefix like phpgb_ then theres no chance of them clashing with
anything else and theres no real reason to continue using a folder for
the main script files .

While the script will have a app folder for various things - does it
make any sense not to use the root because of a single solitary file
called index.php .

phpgb_index.php is what I use and the method hasnt brought up a single
problem of any shape or description .

Gas lighting was once what everybody thought was the best way of doing
it until that darn new fangled electricity came along .

View Replies !
1 - 2 Millions Files In One Folder?
I have to store over a million files, 10 - 15 kb each, in one folder.
The files are created by my php script, sometimes the old files are
deleted and new ones are written.
So, basically on every connection my script reads/deletes/ writes files
from/to that folder.
Right now i have only around 300 000 files in that folder, and it feels
like its getting slower for that script to work. It does work at the
moment, but i am not sure what will happen when there is over a million
files there...
Are there any limits of files that can be stored in a folder?
Would it be better for me to use mysql? I am not sure how mysql will
cope with millions of writes/reads

View Replies !
How Does One Get A List Of All Files In A Folder?
need a list of all files (i have like 5k or so) in a folder, I need to add there names to a table

I am doing this so i can compare two tables

table 1. comments added to uploaded pics -finished pictures-
table 2. no comments added yet to uploaded pics (so they can be commented on GET IT?)  -unfinished pictures-

All the pictures are in a single folder for the time being i'm going to be making a form based on the pictures that are on table 2 so that they can have comments and titles and file name added to table 1 (to be done still) but i need to know all the file names for the folder in question, i guess i could do it via cmd line ls or something like that, i'll get back to you.

View Replies !
Pagination W/ Just Files In A Folder?
Example would be:

prev 12345 next

but doing this with just files and not DB records?

View Replies !
Viewing Files In A Web Folder
I'm trying to put my files in a web dirctory.  All kind of files, so that in the future when I need something I just go there and get them.  My goal is that when I type "www.domain.com/myVitualDirectory" I would get my list of files and folders and files and I would even be able to navigate into the folders, then I would right click and Save Target As and get my file.

View Replies !
Php Include Files From A Folder
I want to make a folder filled with blog posts by date.  Each file will be like 20071113.php and 20071031.php basically the date they were written 2007, 10 for october, and 31 for the day.  But each will be notated like that so that the number is always increasing. 

How would I make a php include function as to take the last ten highest numbers and add it to a page? (Basically the last ten posts by date) and  How would I include more than one post per date?

View Replies !
Counting Files In A Folder
I want to count how many images are in a file.. all are .jpg some .JPG .. how can i do this??

View Replies !
Folder With Files From Server To Another
I am trying to transfer a folder with files from server to another.

I found a script online and it sort of works. What it does is copy files from the root folder (which it shouldn't) and puts into the folder I am trying to copy from.

What I need is it to copy from the $ftproot into the $srcroot/$srcela folder.....

View Replies !
How To Count The Files In Each Folder
I'm using this:

<?php
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/$login"; 
$images = count(glob($dir_path . "*"));
?>
now, <?php
include "scripts/connection.php"; 
if (!$con) 
{ 
  die( 'Could not connect: ' . mysql_error() ); 
   }
mysql_select_db($db, $con); 

$result = mysql_query("SELECT * FROM album WHERE active = 'yes'");
?>
how can i get it to count the files in each folder, ie <?php 
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/client1";
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/client2";
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/client3";
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/client4";
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/client5"; [/code

View Replies !
Copy Files From One Folder To Other Using PHP?
how can i dopy files from one folder to other using PHP? exactly i need to select some files on the server then after clicking submit those files should be copies to a local directory from the server.



View Replies !
What's Your Folder Structure For Your Files?
So, I'm looking to get started on my first application, and my first question is about folder structure on the server and what are the best practices?

When I create static content today, I create one folder per page usually to keep things organized. Any components are included in the related folder, and global components are added to a top level components folder.

I realize the dynamics of PHP will reduce the need for hundreds of pages, and that's why I'm excited to learn this language. However, I still need to keep even the dynamic PHP files and components organized.

I've seen some sites, where people put all their PHP files on the top level folder. Just wanted to get your feedback on how you guys keep your server folder structure organized?

View Replies !
File_get_contents From Files In A Folder
$dir = 'matchreports';
$dh = opendir($dir);
             while (($file = readdir($dh)) !== false){
        $fullfile = $dir . $file;
        $subtotal[] = file_get_contents($fullfile);
I am getting this msg "Warning: file_get_contents(matchreports010407.php) [function.file-get-contents]: failed to open stream: No such file or directory"

010407.php is one of the files i need to retrieve the contents from, including others from the folder.

View Replies !
View Folder Files
i am looking for a script (in php) which would list the contents of a certain folder on my server and be also able to delete selected files.

View Replies !
Security Of Files In A Folder
I'm creating a database for old tests that people have taken. The tests are scanned in and stored in a folder on my server. In order to see them and navigate the many pdf files, you have to login with a username and password. I know how to do all that, but how can I password protect. pdf files on my server so that they can only be accessed from the point after the user has logged in? Everything works dandy except for the fact that people can directly link to a. pdf file (a huge security risk). Also, if I don't password protect the directory of the pdf files, can webcrawlers find the information and store it in their search database?

View Replies !
Putting Files In A Folder
I have a script that makes PHP files. I would like to put them in a separate folder. I mean I want the script to be in a folder and the files it makes in another folder.

View Replies !
Download A Whole Folder Of Files
Is it possible to let a user download a folder with several files? For example a folder with many jpg files? I mean when the user presses a download button or link he will automaticly be downloading all files from the folder.

View Replies !
Number Of Files In A Folder
I want to use a loop to list the file names in a folder. How do I find out the total number of files in the folder so I know when to end the loop? I can't use 'file exists' because the file names could be anything.

View Replies !
Sort Files In A Folder
I've got a bit of a problem. I found a script that reads files from a folder, and I modified it so that it can read image files and give extra info about them. but it only sorts the files by alphabetical order; I want it to sort them by date as well. I've been tinkering with it, but all to no avail. I only got it to sort the files by reverse alphabetical order (rsort()). Here's the whole script:

<?php

$folder = 'http/path/to/folder/';
$imgdir = 'absolute/path/to/folder';
$allowed_types = array('png','jpg','jpeg','gif');
$total_images = count(glob("$imgdir{*.gif,*.jpg,*.png, *.jpeg}", GLOB_BRACE));

?>

View Replies !
Indexing Text Files In A Folder
I'm newbie on Php. I cannot write codes but only modify.
I need a code doing this:
I'll put text files in a folder like file1.txt,file2.txt ...
I want to search this files, list most recent 10 and if files

call, script will put into the site design with <pre> tags.

View Replies !
Dropdown List Of Files In Folder
I am preparing a form that includes a drop-down list consisting of the names of files in a certain folder on the server.

I only need to trap the file name (jpg), not the path and I'm not trying to upload the files or anything - simply allow the user to select one of a number of different image files (they're actually location maps).

View Replies !

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