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.





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

Related Forum Messages:
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 !
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 !
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 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 !
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 !
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 !
PHP/IIS: File Read/Write OK, File Unlink Denied
I've got PHP running fine on IIS (OS: Server 2003, SP1; IIS: 6.0; PHP:
4.3.11).

In PHP, the user uploads a file, which is then processed and the
contents are inserted into a new file, created in PHP, onto the server.

This bit works fine, the new file created by PHP is correctly stored.

Later, once the user confirms the upload and PHP inserts the contents
of the file into the DB, the code tries to remove the file created in
PHP moments earlier, via the unlink() function.

What I see on screen is the following: Permission denied

I have made sure that the permissions for the Internet account that
created (and is trying to delete) the file have full permissions over
this particular folder and the files within it. But the user must have
permission anyway, because they are able to create this file in the
first place.

I've looked at the permissions for the file in PHP, which read: 0666.
So everthing *appears* ok to me; I can't see where the permission issue
is coming from.

View Replies !
Cannot Unlink File
have a delete record code that does the job and deletes the record, im trying to unlink the images that are related to that record. i added a code but it doesnt work. Code:

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 !
Unlink Failed - No Such File Or Directory
I have a script which tries to delete a file on my (unix) web server.

The file (and directory) access is chmod 777 (world readable/writable)...

My script checks to see if the file exists (is_file) which returns true but when I try and delete (using unlink)... it says the following...

Warning: unlink() failed (No such file or directory)

View Replies !
File Manager/Unlink Usage
Another newbie here toughing my way through the PHP world. I have been plugging away at this upload/download script for some time now. I have it working just great with one exception...

I can't delete any files after they have server their purpose. This started out as a borrowed script with my twists and changes to it making it work for me. All I want it to do is list the files in the directory so I can choose which ones to delete. Code:

View Replies !
Download File And Delete File From Server With One Button Click
I want the user to be able to download a CSV file and delete the file from the server all with the click of a button.  Currently, in firefox, it will just display the CSV and not delete it. In IE, it will download the CSV and not delete it. Code:

View Replies !
What Is The Best Way To Delete File ...?
I have script that allows a user to upload a txt file for processing, filtering, to save bandwidth,instead of user reuploading the file everytime he/she does a new process on the same file, i save the file to the server, and process from that file. What I want to be able to do is, when the user uploads a new file, or leaves the site, this temp file is automatically deleted (saves disk space).

View Replies !
Delete File();
I was wondering if php4 has a built in function that could delete a file. In my case I need my php to delete a picture. (jpg, gif) Does php4 have the ability to delete an exsiting file? Something like this?? delete_image("../images/somePic.jpg");

View Replies !
Delete A File
How do i delete a file from my server with php?

View Replies !
Delete File
How do I delete a file with PHP?

View Replies !
Delete File With Php
Im a little new in php, and just made a site where u can upload pictures, but how can i make it possible to delete pictures as well.

View Replies !
File Delete
I need to delete a compressed backup file after it has been sucessfully uploaded to a ftp server, the upload works fine using CRON and a php page. I have tried to delete the file using:

<?
$oldfile = "/home/#*$!/backup-10.8.2005_07-00-01_yyy.tar.gz";
unlink($oldfile);
?>

However I get a permission denied, what's wrong? Also, I don't know the exact file name, so what I really want to do is wildcard the file name like this:

<?
$oldfile = "/home/xxx/backup-*_yyy.tar.gz";
unlink($oldfile);
?>

Is this possible?

View Replies !
Using Php To Delete A File In A Directory- Help
I can use php to execute the cp command to copy an image file into a directory.

Now I want to delete images in that directory if they are not named "picturelink.gif" when an entry with a corresponding id is deleted.

Below is the code I am using which doesn't seem to be working when it comes to deleteing the file. The directory has the correct permissions for read/write access.

$query = "DELETE FROM $userstable WHERE id ='$id' ";

if($picture != "picturelink.gif")
{
exec("rm $picture /virtualhosts/capefearantiques.com/www/pictures/$picture");
}

View Replies !
Delete Lines From File:
How to delete $n first lines from $str if i know how much lines shuld remain in the string?

$str = "aaaaaaaaa
bbbbbbbb
ccccccccc
ddddddddd
...
zzz";

Can it be done easly with preg_replace? (i.e without splitting it by '', removing elements from array and joining tham back.

View Replies !
How Do You Delete A File From A Listing Please?
I have the code:

<?php
if ($dir = @opendir("../project/proj_images")) {
while (($file = readdir($dir)) !== false)
if($file != ".." && $file != ".")
echo "<tr><td align="left" class="bodyblue2">$file</td></tr>";
closedir($dir);
}
?>

which displays a list of files in a directory.

What I want, is to be able to click on a file in the list and delete it.

I know you use unlink but how do you tie it in with the above code?

View Replies !
Can I Delete A File From A PHP Script?
Is it possible to delete a file(a jpg in fact) from a PHP script. I would like to ad this functionality to an existing script that deletes a record from a MySQL db. Only the image name is stored in the db.

View Replies !
Php File Delete Form
How would i go about making a file delete form in php. so that the user can delete .jpg and .gif files from a web directory.

View Replies !
How To Delete Last Line Of File
I have a flat file on the server which I append to from a HTML web form.
I need to delete the last line of the flat file before I append though.

How do i do that?

I have the following code. I'm not sure if it's correct.

$pattern = "</member>"; // what I want to look for.
$ora_books = preg_grep($pattern, file('/path/to/your/file.txt'));

View Replies !
How Can I Have Permissions To Delete A File?
How can I have permissions to delete a file? example: I have to delete a file, but I don't to public users have permission to delete that file but, with a certain "login" they can.

View Replies !
Delete Lines From A File
Can someone show how I open a file and delete everything in it except for the last 20 lines.

View Replies !
Use PHP To Delete An External File?
Is there any way to use PHP to delete an external file?

View Replies !
How To Delete N Lines From The Top Of A File?
I'm not sure how to do this in php - need to calculate and delete an unspecified
number of lines from the *top* of a file.

<?php
//append $visitor to the bottom of $visdata
$fp = fopen($visdata,"a");
fwrite($fp, "
".$visitor;)
//count the lines in $visdata
$lines = count($visdata);
if $lines > 10
{
//delete as many lines off the top as necessary
//to end up with 10 lines total in $visdata
}
fclose($fp);
?>

View Replies !
How To Delete Log File In The Given Period
I dont have much knowledge og PHP. i need to delete log files in the given period. so i need to know how to delete file content using php. i know how to read file content. but i dont know how to delete file content.

View Replies !
Delete File Contents
Can someone post some code to show me how to delete a file from a folder please? I need to delete a file first, and then upload something in it's place. Maybe a bit of code to slide in what i have already would work? Code:

View Replies !
Mysql Row And File Delete
I have a database with the following colums, imageID, imageName, imageDesc, imageFile, imageHeight, imageWidth, imageThumb, imageThumbHeight, and imageThumb Width. I can easily delete a row from the mysql table, galImages, but I also want to delete two files from a directory. The file names are stored in the columns imageFile and imageThumb.

View Replies !
Delete A File Within A Directory
Is there a way to delete a file within a directory using a link?

I have a script that will list all the files in a directory and, in the output, I'd like to create a link next to each file that says "delete This file" and then will delete the file from the /dir

filename1.jpg delete file
filename2.jpg delete file
filename3.jpg delete file
filename4.jpg delete file

I try but when I click on the delete button I delete all the files of the /dir...

View Replies !
Delete File Content, Possible ?
I would like to know if it is possible to delete the content of a file or overwrite the content of a file or even delete / overwrite a certain part of the filecontent, for example a given line-number ?

I have searched php.net for a function but couldnt find anything in that direction. Did I missed something ? Or is it not possible ?

View Replies !
Delete From Db If Not In Excel File
A while back I had written a script for a client who had wanted to upload an excel file for his clients that contained their inventory information. I had it set so everytime he would upload the file it would check the information in the file against that already stored in the db.

If a row in the db contained a certain field like an account number. It would make any changes that were made to that field or if none were made it would leave it be. If there were any new rows in the file it would upload those. Code:

View Replies !
Php File Delete Coding
i would to do a little advance php file delete coding that does a check if any other records are using that image file before it deletes. How would i modify it? PHP Code:

$myFile = "upldimg/".$_GET['thumb_filename'];
unlink($myFile);

View Replies !
Delete File From Directory
If I have the URL to an image in my directory. How can I use PHP to delete that file?

View Replies !
Is It Possible To Delete Everything From A File Between Two Points
Is it possible to delete everything from a file between two points, if I'm not entirely certain what that text will be?

For example, if my file looks like this:
Hello World! Code:

View Replies !
How Do You Delete A Zip File From A Directory?
Once again, I thought my class method deleteZip() would do the trick, but it never deletes any .zip* file found in a directory: ....

View Replies !
Delete Running File
Is it possible to delete the file itself whilst its running? For eg..

unlink("thispage.php");

View Replies !
How Do I Delete A Directory File Using
Is there a way using php code to delete a file in a directory and have it disappear? I say dissappear, because I want the file gone, not just its contents overwritten with nothing.

View Replies !
Can't Delete File From Server
I've pawed through previous posts and tried a bunch of the suggestions to delete files on my web server. I use Filezilla to UL stuff and lately the connection has broken a couple of times and I'm left with a couple of files that are named with complete jibberish. I can't chmod, rename, delete, etc. any of them. Code:

View Replies !
Flat File Delete Row
Does anyone know how to delete just a single row in a flat file database using php?

The "w" function deletes the whole file. Is there a tutorial anyone knows about with examples of this?

View Replies !
Delete A File In My Web Server
I have mysql database and a web page to upload files to my webpage, I know how to delete them from the database, but didnt find the code to delete them from the web server. Please help me with this code.

View Replies !
Not Enough Permissions To Delete A File
I want to delete a file using unlink() function. I'm getting a warning that says that I have no permissions to do that.

I suppose that is because the file I'm trying to delete is under the root directory path. I searched the forum about deleting files but found nothing alike my problem...

View Replies !
Delete File After Headers Sent
Is there any way how to delete a file after download headers have been sent? This code does not work for some reason.

header('Content-type: application/xml');
header('Content-Transfer-Encoding: binary');
header('Content-length: '.filesize($f));
header('Content-Disposition: attachment; filename="'.basename($f).'"');

if($fp = fopen($f, "rb"))
{
while ($buffer = fread($fp, filesize($f))) print $buffer;
fclose($fp);
}

unlink($f);

View Replies !
Delete String In External File
I must: open a file, keep out a string and delete it.

View Replies !
(force) Delete A Session File, How?
I dunno if this is meant for here or apache anyway.. my script uses sessions... if the person logsout.. the session is closed and the session file is deleted.. if the person just shuts down the browser the session file is not deleted and hence i've got hundreds of redundant session files.

View Replies !
Delete A File That Is Located On A Server
I want to delete a file that is located on a server. The filename is in a Mysql database and now I have to put the line 'system("del c:apachehtdocsshopimg.gif");' somewhere in my code underneath. Any Idea how ? This line works already, but now the '.GIF' has to become a $file that equals the filename from the database...

View Replies !
Delete Flat File Content
Just have a basic notes.txt to which notes are obviously added to. However, i would like a page "delete.php" to have all content within that file deleted, but keep the notes.txt file intact.

View Replies !
Delete Or Post To Print Txt File Or Pdf
i have a file that loads all my records from a table in my database. What i want is to add the option of posting the info in a selected record to a file, either a pdf or text file so that it is printer friendy. At the moment the only option available is to delete the record, can i add another button to my form to do what i am aiming?

View Replies !

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