|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Deleting an image file with php
I can upload jpg images to my server no problem. The images take on the names of the id field in the MySql database followed by front and back
eg 3456front.jpg 3456back.jpg As the database is going to be quite large, i have found this to be the best way rather than adding blob fields to the db. I then just echo [id]front.jpg and [id]back.jpg as the image urls. Problem is, i have an admin page that allows for deleting records from the db but i am unsure how to delete the images from the server with the corresponding [id] number. Hope someone can help me out with this. Thanks. |
|
#2
|
|||
|
|||
|
Here is a very simple script file I use.
PHP Code:
Hope this helps....I also delete the information in the database after the file is unlinked.
__________________
Thanks, Attila http://www.glorynaspiration.com http://www.abitofthings.com |
|
#3
|
|||
|
|||
|
You'll need to be very careful with a script that deletes files. If you're not, it will be easy for someone to delete arbitrary files from your site. That is the big disadvantage of not using a database to store your files.
Hadley |
|
#4
|
|||
|
|||
|
Thanks for you help and advice. It's dificult for me at this stage to decide on weather to hold the images in a blob field of the database or just a link reference as most of the articles i've read have conflicting advice.
I plan to have all my admin scripts in a folder with an .htacess file to password protect the whole folder. Is this the most secure password method of protecting all my admin scripts. Basically I want all my admin scripts to be as secure as possible and I imagine the datadase to become quite large and i'm led to believe that having many thousand image files in the database will slow the site down conciderably hence the reason for having a link ref field instead. I don't want to just leave files on the server where the database entry has been deleted as this will just waste valuable space on my chosen hosts server. |
|
#5
|
|||
|
|||
|
I would question your assumption that having many image files in the database is going to slow your server down. All a database is, really, is a way of indexing files on disk so that you can find the ones you want rapidly.
I have a site with well over 50meg of files stored in a mySQL database and have not had any performace problems. Hadley |
|
#6
|
|||
|
|||
|
Thanks again Hadley for your reply. This is what I mean by conflicting advice between different articles i've read. Some say storing large image files in a db will slow the site down and some say it makes virtually no difference.
I can't make any assumptions myself apart from things i read written by the pros as i'm quite new to all this, but it is hard with so much conflicting info out there. I think my only solution really is to try things out for myself. Once again thanks for your help. |
|
#7
|
|||
|
|||
|
Quote:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Deleting an image file with php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|