| | |
Help on Deleting files from server- no database
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jul 2007
Posts: 29
Reputation:
Solved Threads: 0
Hi everyone, I want to delete uploaded files from the server. here I am not using database please check my code and suggest me any changes
Del.php
jpgview.php. From this file del.php will be called
My problem is I am unable to get the buttons corresponding image name and send it to del.php
Thanx in advance
Del.php
PHP Syntax (Toggle Plain Text)
<?php $jpgdir = "uploads/"; $file=$_REQUEST['file1']; echo $file; //echo $jpgdir; // Open a known directory, and proceed to read its contents if (is_dir($jpgdir)) { if ($dh = opendir($jpgdir)) { unlink($jpgdir . "/" . $file); closedir($dh); } } ?>
jpgview.php. From this file del.php will be called
PHP Syntax (Toggle Plain Text)
<?php $jpgdir = "uploads/jpg"; $dh = opendir($jpgdir); echo "JPG FILES"; print("<form name=del action=\"del.php\">"); print("<table border=2>"); while (($file = readdir($dh)) !== false) { if($file!='.' && $file!='..') { print( "<tr><td>"); echo "<A HREF=\"$jpgdir/$file\"><IMG src=\"$jpgdir/$file\"/ height=70 width=70></A><BR>\n"; print("</td><td>"); echo "<input type=\"submit\" name=\"del\" value=\"Delete\" id=\"$file\">"; print("</td></tr>"); } } print("</table>"); print("</form>"); closedir($dh); ?>
My problem is I am unable to get the buttons corresponding image name and send it to del.php
Thanx in advance
Try this.
This lists all the images in the specified folder.
This code deletes that image and sends the user back to the image listing page.
This works.
Cheers,
Naveen
This lists all the images in the specified folder.
php Syntax (Toggle Plain Text)
<?php $jpgdir = "./uploads/jpg/"; $dh = opendir($jpgdir); echo "JPG FILES"; print("<table border=2>"); while (($file = readdir($dh)) !== false) { if($file!='.' && $file!='..') { print( "<tr><td>"); print("<form name=del method=post action=\"del.php\">"); echo "<A HREF=\"$jpgdir/$file\"><IMG src=\"$jpgdir/$file\"/ height=70 width=70></A><BR>\n"; echo "<input type=\"hidden\" name=\"path\" value=\"$jpgdir/$file\">"; print("</td><td>"); echo "<input type=\"submit\" name=\"del\" value=\"Delete\">"; print("</td></tr>"); print("</form>"); } } print("</table>"); closedir($dh); ?>
php Syntax (Toggle Plain Text)
<?php $jpgdir = "./uploads/jpg/";; $file=$_REQUEST['path']; // Open a known directory, and proceed to read its contents if (is_dir($jpgdir)) { if ($dh = opendir($jpgdir)) { unlink($file); closedir($dh); } } header("location: jpgview.php"); ?>
This works.
Cheers,
Naveen
Last edited by nav33n; Feb 2nd, 2008 at 7:52 am.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- Spyfalcon & Malwarewipe, and I can't get ride of it! (Viruses, Spyware and other Nasties)
- Virus ALert! (Viruses, Spyware and other Nasties)
- guidence urgently needed! (IT Professionals' Lounge)
Other Threads in the PHP Forum
- Previous Thread: Newby to PHP here.... (Google Analytics)
- Next Thread: fopen fwrite in php4
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date decode display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail match menu mlm mod_rewrite multiple mysql mysql_real_escape_string oop paypal pdf php problem protocol query radio random recursion regex remote script search server sessions sms smtp soap source space sql strip_tags survey syntax system table tutorial undefined update upload url validation validator variable video virus web window.onbeforeunload=closeme; xml youtube






