|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Is it possible to delete jpg and gif files from off the server with code processed by an ASP page?
If yes, can anyone suggest suitable code? I'm putting a site together for a photographer. He can now add pictures to a mySQL database, edit descriptions etc. All linked with ASP, then using php to physically upload the pictures to the server. He can already delete the picture from the database, but I wanted him to be able to physically delete the jpg images as well, when he clicks on delete. I'm still new to ASP, my book suggests its possible but then does not cover the how. Johnie |
|
#2
|
|||
|
|||
|
use the FileSystemObject
Hi Johnie,
If you know where your file in located in the filesystem you can delete a file using the following code: Code:
Dim oFSO
Dim sMyFile
'instantiate object
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
'physical path to the file name
sMyFile = "c:/inetpub/wwwroot/images/deleteImage.jpg"
'check if file really exists
If oFSO.FileExists (sMyFile) Then
oFSO.DeleteFile (sMyFile) 'delete file
End If
'release resources
Set oFSO = Nothing
If you are not sure about the path name to your file, but you know the virtual path to the location to the file you can use the Server.MapPath method So change the line sMyFile = "c......." to: Code:
sMyFile = Server.MapPath("/images/deleteImage.jpg")
and ASP will find the physical path to the file for you here you can find all fileSystemObject methods and properties: http://www.devguru.com/Technologies...stemobject.html Good luck
__________________
- Rogier Doekes |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Deleting files with ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|