phpfan Posted August 8, 2007 Share Posted August 8, 2007 Hi php coders!!! I am developing a website that requires to upload, update and delete images. I have successfully managed to upload and update the required pictures but i have some problems when i try to delete the images. Actually i am using the unlink command in order to delete the images but the image is not deleted form the server. Because my client needs to upload images frequently, we cannot afford keeping the old images on the server. How i can actually delete the images and remove them from the server? Thanks for the help in advance Quote Link to comment https://forums.phpfreaks.com/topic/63907-solved-how-to-delete-images/ Share on other sites More sharing options...
gerkintrigg Posted August 8, 2007 Share Posted August 8, 2007 you need to use unlink() but you'll need to make sure that path is correct... the easiest way to do that is to navigate to the right address for the image and work out what it looks like before trying to copy the structure of the image URL in such a way that it will work for all subsequent dynamic deletions. Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/63907-solved-how-to-delete-images/#findComment-318524 Share on other sites More sharing options...
phpfan Posted August 8, 2007 Author Share Posted August 8, 2007 Hi I have tried using the unlink command but the image still remains in the folder, on the server i want to actually delete the image like using the delete option in windows. Is that possible? ??? Quote Link to comment https://forums.phpfreaks.com/topic/63907-solved-how-to-delete-images/#findComment-318694 Share on other sites More sharing options...
tarun Posted August 8, 2007 Share Posted August 8, 2007 Are You Sure...? Maybe You Could Move The File To A Kind Of "Too Be Deleted" Folder Then You Can Manually Delete It Your Self Bit Over The Top But I Dunno What To Suggest Quote Link to comment https://forums.phpfreaks.com/topic/63907-solved-how-to-delete-images/#findComment-318800 Share on other sites More sharing options...
DjMikeS Posted August 8, 2007 Share Posted August 8, 2007 Who is going to say the magic words... okay I'll do it... Post some code Quote Link to comment https://forums.phpfreaks.com/topic/63907-solved-how-to-delete-images/#findComment-318909 Share on other sites More sharing options...
teng84 Posted August 8, 2007 Share Posted August 8, 2007 Hi I have tried using the unlink command but the image still remains in the folder, on the server i want to actually delete the image like using the delete option in windows. Is that possible? ??? i guess unlink or delete can do that if you specify the right file name or path Quote Link to comment https://forums.phpfreaks.com/topic/63907-solved-how-to-delete-images/#findComment-318912 Share on other sites More sharing options...
duniya Posted August 9, 2007 Share Posted August 9, 2007 It might be a permission issue. Does the php process have correct permissions on the folder/images to delete the images? Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/63907-solved-how-to-delete-images/#findComment-319204 Share on other sites More sharing options...
mrjcfreak Posted August 9, 2007 Share Posted August 9, 2007 first up, use is_file() to check the path is correct, and even if you're fussy use getimagesize() - this will tell you if your path is right. Second- check permissions. chmod the image to 0777 and see if your script will delete it. Quote Link to comment https://forums.phpfreaks.com/topic/63907-solved-how-to-delete-images/#findComment-319211 Share on other sites More sharing options...
phpfan Posted August 9, 2007 Author Share Posted August 9, 2007 Hi I finally manage to solve the problem. As everybody guide me the unlink command actually can delete the picture i was just passing a wrong variable to the command and although that the system seems to work ok the picture was not removed. Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/63907-solved-how-to-delete-images/#findComment-319804 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.