ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 19th, 2002, 03:52 PM
Johnie Johnie is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: North Devon - England
Posts: 20 Johnie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 5 sec
Reputation Power: 0
Question Deleting files with ASP

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

Reply With Quote
  #2  
Old November 20th, 2002, 12:29 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 7
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Deleting files with ASP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway