Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing an Image from Server

Status
Not open for further replies.

GavW

Programmer
Jan 13, 2006
58
GB
Hey all!

Was wondering if anybody could help me with this problem. I have managed to implement my image upload feature, offering a user the ability to replace their profile image.

The only problem is that all of the old images still remain on the server and worse still if a user wishes to change back to the image they were using previously then an entirely new file is uploaded with a different name.

The tutorial that I have used to perform the uploads is at:
could anybody help me add to this script to include functionality to remove an image before a new one is uploaded.

Thanks
 
Thanks for the help.

I am having a bit of trouble with the File.Delete method however. I am attempting to delete a file situated inside of the "/images/photos/" directory from the root directory but I am receiving this error:

"Could not find a part of the path 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\forum\images\photos\file.jpg'."

Clearly the method is looking in the wrong location for the "/images/photos/" folder. How can I get it to point at the correct location?

Thanks
 
File.Delete("/images/photos/file.jpg");

I will replace the string with a variable as soon as I can get it working.
 
User Server.Mappath to get the path and then append the filename.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top