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




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 Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Deleting All Files
Is it possible to delete all files in a folder using unlink() or something similar?

Deleting Files
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:

Deleting Files
I'm using different files to store some arrays to make administration of a very small job-logger very easy. I currently read the file, remove the element to be deleted, delete the whole file, and write the file again without that element. Is there a way to remove a single element out of that file without deleting the whole file?

Deleting Files
I'm trying to modify this script to remove files that end with %enlarged.jpg or %enlarged.gif or %enlarged.png, can someone help with the if statement, I've tried several things, of which, nothing is working: Code:

Deleting Files
I have some script that takes an album id and deletes that album and the specific photos in that album. The code does run. The problem is that an error message i set to echo appears saying error deleting photo once the page automatically refreshes. When i check the image folder the images actually have been deleted. Code:

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?

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.

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?

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?

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:

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".

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.

Deleting File(images) From Server
I want to be able to delete images I don’t use from my image directory on the server. Deleting images from my Mysql database goes well, but I can’t delete them from server directory. I use this simple function but even the path is right it doesn’t work. Code:

Deleting Session File From Server
A session is deleted after the browser window is closed. I have been trying to work out why the session file remains on the server (it is named something like sess_3ghy6...) and has to be manually deleted. I want to avoid having hundreds of these files collecting on the server ....

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.

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?

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

Files Move From Server To Server
I moving to a new server. Is there a way that I can do this without downloading all my files and uploading them? Is there a script that can do this?

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?

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.

Deleting A File From Server Through A File List
I've been having trouble with this for a while. Ages ago I made an upload script that lets you upload to files/upload/ and then once you upload it, a piece of PHP will show the files in that folder.

In the admin section of my page i'm trying to find a way to delete the files off the server without having to dig into the FTP and do it manually.
Are you able to do that with PHP? Code:

PDF Files On The Server
I create pdf files on my unix server using php and a very useful utility from http://ros.co.nz/pdf/.
Due to many IE problems I have found the best way is to save them to disk rather than streaming them and then redirect the user using javascript.
The problem is that the file is then on the server. I can write a cron to delete the files every so often but the files contain sensitive information so I would not want them to be accessed by just anyone.
My main site is password protected through php and mysql. I have thought of using .htaccess files but then the user is asked for a username and password even though they are logged in to my system. Is there anyway of securing these files?

Uploading Files To Sql Server
I'm trying to upload files (into an image field) and then download them, but my files are reduced to 4096 bytes after the downloading. I've tried to execute the query "set textsize=60000" before each select, but this seems to have no effect. I read the files and execute the queries from php 4.2.4.

Transporting Php Files To A Mac-server?
Run into some problems when transporting my php filez to a mac server (it is unix based, right???). Somehow, some of my variables (1 out of 3) would not show up. I needed 3 vars to make a mysql-query. I fixed it by using $_REQUEST['var'] for just one variable, but for the other variables i did not use it and it works.

Uploading Files To A Web-server
So here's the deal; I'm hosting several people on a virtual server
running Linux (White Box Enterprise), each of which has an internet
presence. (Apache webserver.) They're also web novices. I want to
develop a method by which they can upload photos to a folder on the
server from their client computer, without having to use FTP, creating
the folder if necessary. This would be accessed from the client-side
from a signed applet. How could this be done, short of granting
univeral write access in the folder? Is there a way (for instance)
that a user can access their remote account with the rights of their
local user? I.E., as if they'd logged in via FTP? This should run as
quietly as possible, not requiring HTML forms and the like.

I'm new to Apache programming, so I'd appreciate any links to
possibilities for doing this, or any projects that've already done it.

Copying Files From One Server To Another
I am trying to set up a link excahnge program using php and I need to know how to copy a file from one server to another. See when people change the banner they have displayed they can enter the location of their banner, such as http://them.com/banner.gif and then i need to copy it over to my server and into there dir, such as www.me.com/them/banner.gif. Does anyone know how i can do this. I have tried many things but nothing has workd so far.

Server Generated PDF Files?
Heres what I need to happen now, I know how to do most of it, except the generated PDF form.

- The server puts that information into a PDF file with a background of my chosing and emails it to a specified adress. (Its already set up to send the email)

My issue is I dont know how to have the server generate the PHP form. How does it work? How do I position the text over the PDF automatically?

I'm already donating $10 to the site, thanks to the help I received from UTAlan, Lytheum, and Waldir. Ill make it a total of $20 after this.

Selecting Files From Server With Php
I made a little app that opens a html file into fckeditor then after edit saves the html file. I would like to add a drop down list or whatever is best, so i can select from files on the server to edit. How would I accomplish this
task.. in the simplest form since I am a newbie..

Saving Pdf Files To The Server
I am trying to save pdf documents to the server. I would prefer that it is not shown to the user. What I am trying to achieve is to create a pdf, save it to the server, and then email it as an attachment

Is this possible, and if so How is it done?

Including Files In Remote Server
I have a perl script to grap headlines from slashdot and such for me, and I use corn to have it run hourly and put the headlines in a file on the linux server.

Now problem is that my site is sitting on a Windows 2000 Apache Server. So I can't seem to use include() to get the file into my page. Any suggestions or alternatives?

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.

Nobody User When Upload Files On Web Server
This time I've got a terrible big problem about
the interaction between a PHP application and the web server filesystem.

The PHP application has got many funtionalities, such as uploading small image or text documents, creating directories, and so on.
Once I log on the web server filesystem, I notice that
all the files have been uploaded correctly, but their ownership is of "nodody" user, "nobody" group and 754 permission.

I would like such files should have the same owner of the web files on the server, i.e. "pippo".

Moving Files On A Linux Server
I need to find a way of moving files on my linux server using PHP. Because of security the folders I am moving files to require you to be logged in as the super user.

Problem Using PHP For Server Files Redirect
We are trying to set up a PHP page to handle server requests for
individual web pages that we are moving to a new server. The part that
complicates this procedure is that the files will not be mirrored on the
new server. Instead many will be residing in new directories and
subdirectories than they were in on the old server.

What we wanted to do was when someone requested a specific page from our
old server, it would recognize the non-existent page and send it to the
redirect.php page that we created. That part works fine. Unfortunately,
PHP is unable to see what page originally was requested. I thought it
would see one page back, but it doesn't.

Is there any way to get the redirect.php to identify what the called for
page was so it can redirect it forward to the place the file resides in
on new server properly? I know this would be simple if this was from a
form but it's not.

Generating A List Of Files On Another Server
I have been messing about with the folder / file functions on the php.net website but they all seem to be for local folders.

All I am trying to do is generate a list of files on another servers folder - so my variable to generate a list from would be "www.tnauk.org.uk/bbs/daily" but the script would be running on nimmox.com. Is it possible?

Saving Uploading Files On The Server
i am about to start writing a script that uploads files to my server.
the code for the form i want to use is:

<form enctype="multipart/form-data" action="savefile.php"
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>

using the action script (savefile.php), how do i them save the file in
a folder on the server?

500 Server Error Loading Php Files W/iis
I'm sure this question has been asked many times, but I couldn't find a thread that related to my setup, so I have to ask. I have a Windows XP pro machine setup w/IIS 5.1. I've got html, perl, and asp pages setup and working fine. But for some reason, I keep getting a file not found/500 server error when I try to load a simple php file.

I tested the file in the command prompt and it outputted the results as expected, so I know it's not a php problem. I'm using the dll file that I copied into the windows/system folder to load the scripts and setup a application configuration and filter setting, and stopped/started IIS. Same error.

Script That Can Run Executable Files On A Server
I am looking for a script that can run Executable files on a server, I have leased a dedicated server but the company doesn't allow remote desktop access to it, so I can't run them, we have uploaded server files to a dedicated server but can't run them, they are exe files.

Required Files Confused Between Applications On Same Server
I'm running PHP 5.2.0 on my Windows XP laptop, running under IIS. I
have files named 'config.php' in two different web applications on
this machine, which are included throughout each via 'require' in one
and 'require_once' in the other.

When I attempt to use the two applications simultaneously, the file
which was 'require_once'-ed is also being accessed from the other
application, even though the two applications are isolated from each
other in IIS, and are in completely different directories on the
computer.

Uploading Mp3 Files To Folder On Server Via Php Form..
Im trying to design a webpage form in php that allows uploading of three mp3 files to a folder on my server. The webpage should convert the name of each mp3 file uploaded to 1.mp3 , 2.mp3 and 3.mp3 and whenever a new song is uploaded it should replace whatevers in the folder on the server, im totally stuck as where to begin.

Download Files From Remote Server To Local Webserver
I am trying to create a php page whereby people can download files from a remote server to their own server (to update their webdirectory with updated files/images etc). So for example one php page (e.g. update.php) should be able to download files from a remote server to a specific directory on their local webserver. Is this possible?

Making A Database Backup To Local Server And Upload Files To Another?
I want to make a script that backups the *.frm and *.MYD files to my server and I also want to upload those files to another server via FTP? I have a copy of the database files in the directory, that works fine. But my ftp part doesn't! PHP Code:

User Uploading Files To Load Balanced Server Cluster
This really is a file permissions problem ... although I'm not sure how
to solve it. Any assistance would be greatly appreciated.

I have a series of load balanced servers. Each of the servers is
arranged exactly the same and handles file uploads from users as
follows:

1) User submits file to www1 server
2) www1 server saves file with permissions showing user "www" is the
owner, dir owner is the group for the file ("sg" in this case).
3) cron script on www1 scp's the file to www2 server.

All of this works great up until the following happens ...

4) User resubmits the file to www2 server
5) www2 attempts to update file located on www2 server with new
version, but cannot modify file (attempting to overwrite a file owned
by sg/sg with a file to be owned by www/sg).
6) User continues to see old image, new image is not replicated

PHP Class/library Zipping Client Computer Files And Upload To Server
Can anyone suggest good PHP class/library that can zip client local
files and upload to the server? Single package is great as well as
separate packages.

Deleting
how could i delete everything from a table in a mysql db except for the 10 latest things ?

Deleting The Saved Db The One Before?
I made a script that backups the database as sql file in the server. I mean script writes it into the harddrive, but everytime when i execute the script the harddrive loss another 3 mb. How can i modify the script to delete the one before when i execute it to write the new one?

Need Help With Deleting Records
I'm trying to add a link on the display of a record to delete that record.

The main part of the record is stored in pw_event, then there are several rating fields for that record stored in pw_rate, and there is also several records for the first record stored in pw_whois.

I need to have a link that will deleted everything for that record in all three tables.

Here is my display script:

PHP Code:

Deleting Last Comma
The code below displays pet names like so:

Fido, Bowser, Kittycat, Spot,

and I want to delete only the last comma. I tried 'substr' and 'rtrim' and both of those delete the space and comma between each name, not just the last name as I'd like, so I end up with:
Fido,Bowser,Kittycat,Spot,

How would I delete only the last comma, so that it is this instead?
Fido, Bowser, Kittycat, Spot

Even with trim and substr, I end up with:

Deleting A Session
I want to be able to delete a session so that the next time there's a call to session_start, it creates a new session ID. I don't want to destroy the session variables specifically (though this will be a side-effect of what I'm doing) so I know that session_destroy isn't what I want to do.

I presume I should just delete the session cookie manually. Is there a neater way? And if not, how do I do this?


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