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 Complete Forum Thread with Replies
Related Forum Messages:
Listing Table Data With An Option To Delete Each Individual Item.
Was wondering if anyone could help me with a PHP, MySQL problem. I am completely new to PHP and MySQL. I have been trying to find a way to list data from a table on a web page and after each individual item have a hyperlink to allow users to delete the information listed. Can anyone help? i.e. Name Age Sex ------------------------------------------ Adam 21 M delete Betty 22 F delete Chris 23 M delete Daisy 24 F delete ------------------------------------------------------------------------------------------------------------------------------ (delete after 'Sex' would be the hyperlink to delete that entire line (row) from the table).
View Replies !
File Listing Error!
I've been having trouble with my php code lately, first when i tried to make it so noone could leech files with some .htaccess stuff i got 500 internal server error's, when i removed it [.htaccess] my script stopped working completely, can you please check the code and see what i did wrong (note: this script is supposed to display all the files in the directory. Using a Include) PHP Code:
View Replies !
Directory File Listing
Was wondering if anyone has already built something that can list all files and directories sub directories.. I can list files and directories, But im wanting to do it with a twist... DIRA --filename.txt --filenameb.txt DIRb --something.jpg --subDIR ----filename.txt I would like to list them in some sort of tree view instead of listing the flat out... Any ideas? Or pre-written scripts?
View Replies !
Listing Date - Creating Permanent Listing?
I have a script that has a drop-down for how long the listing will be published. Right now, it uses the following to decide between 2 weeks, 1 month, 3 months, or 6 months: $cadate = time(); if ($gueltig == ཊ')$caend = $cadate + 1209600; elseif ($gueltig == ཚ')$caend = $cadate + 2592000; elseif ($gueltig == ྖ')$caend = $cadate + 7776000; elseif ($gueltig == 餎')$caend = $cadate + 15724800; else$caend = $cadate + 1209600; $deltime = strftime(""._CLADS_STRF."",$caend); I know this is a stab in the dark, and without seeing the rest of the code, is there another elseif I can add so that the listing will be there permanently?
View Replies !
Directory Listing With File Info
I'd like to make a directory listing where instead of the entire filename I need it to show the filename minus the extention and get the value of charname= in the file itself. I've been told that I had to turn the directory listing into an array and then use "foreach (array as item)" to go through and open each file but I've tried several different approaches and I just can't get it to work. I've been able to make it list the directory in order using this script but after that I'm lost. <? $list = Array(); $handle = opendir('testdir/.'); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $list[] = ($file); } } closedir($handle); sort ($list); reset ($list); while (list ($key, $val) = each ($list)) { echo "<a href=test.php?name=$val>$val</a><br>"; } ?> Here I'd like the $val after the name= to be just the filename without the extention (all files in the directory are txt files) and then the second $val which it shows in the list to be the value of the line charname= in the txt files themselves.
View Replies !
File Listing And Extract FileName
1) Any way to list files in a foder, ORDER by DATE_MODIFIED DESC ? 2) I have this: http://www.mysite.com/groups/hard/ap6434.htm How can I get or extract the filename from the url ?( get ap6434.htm as result )
View Replies !
Uploading And A File Listing Script
i was looking up basic ways to upload and i have a fully working upload. But what im looking for is if there is a way so that It can compare the data bettwen the file being uploaded and a file in the same folder with the same name...That way it wont upload the same file twice/override the old one, and if the new one has diffrent text inside it will put the new one in but just have like (1) after the name and so on. Also im looking for a basic way to list all the file names and then next to that have it say Download and if you click that it will be a link to the file so they can download it. I know this seems liek a lot or w/e but im working on it my self not just begging for script.
View Replies !
Limited Server Directory / File Listing ...
I wish to provide a limited file listing ... of the files that are on the server to my client. So they can choose an html file to edit and then save it back to the server? Does anyone have a clue as to where I would start, or what functions I can use to navigate the directory structure in php?
View Replies !
Creating Txt File Listing Variables Used In Script/site
I need to upgrade one of my sites to non Global_variables and am looking for a script or windows app that would go through the script and create a txt file listing the variables used in my script. I started to do it myself manually but this is a dating site script that I hired a programmer to create for me to my specs and there are hundreds of variables if not more. I just moved to a new server and the script had errors because the phpini had Global_variables off. 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 !
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 !
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 !
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 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 !
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 !
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 !
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 !
(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 !
Delete Temp File On Server
I am using the following to generate an xml doc to the users browser: $fp = fopen("document.xml", 'w+'); $str = ($xml_frame->Fields('top_xml').$content->Fields('xml').$content->Fields('xml').$xml_frame->Fields('bottom_xml')); fwrite($fp, $str); fclose($fp); header( 'Location: https://www.website.com/document.xml') ; I would like to delete 'document.xml' after it has been loaded to the user's browser but unlinking the file kills it before it loads and sleep hangs everything. I there a way to detect when it's finished downloading to the user?
View Replies !
Simple Delete Of File Question
I have a dynamic list of images Code: $files=directory("../photos/","jpg,jpeg,Jpg,JPg,JPG"); foreach($files as $pic){?> <img width="150" src="<?php echo $path.$pic;?>" align="bottom" /> <input type="button" name="Submit<? echo $ct?>" value="Delete" /> <?php echo $path.$pic;?><br/> <?php }?> There's got to be a simple way to have this button delete just that file.
View Replies !
|