soccer022483 Posted March 15, 2006 Share Posted March 15, 2006 I'm creating a classified ads system online. Here's my problem: When someone creates a new ad, they can upload an image. If they upload an image, but end up not creating the ad, I need to delete the image. Do you think this is the best way to do it? Quote Link to comment Share on other sites More sharing options...
greycap Posted March 15, 2006 Share Posted March 15, 2006 [!--quoteo(post=355214:date=Mar 14 2006, 09:54 PM:name=soccer022483)--][div class=\'quotetop\']QUOTE(soccer022483 @ Mar 14 2006, 09:54 PM) [snapback]355214[/snapback][/div][div class=\'quotemain\'][!--quotec--]I'm creating a classified ads system online. Here's my problem: When someone creates a new ad, they can upload an image. If they upload an image, but end up not creating the ad, I need to delete the image. Do you think this is the best way to do it?[/quote]Its ok to have a clean-up process on an aborted transaction. Another solution is that, because it sounds like an image is optional, only allow image to ads that have been already been created. Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted March 15, 2006 Share Posted March 15, 2006 [!--quoteo(post=355273:date=Mar 15 2006, 08:35 AM:name=greycap)--][div class=\'quotetop\']QUOTE(greycap @ Mar 15 2006, 08:35 AM) [snapback]355273[/snapback][/div][div class=\'quotemain\'][!--quotec--]Its ok to have a clean-up process on an aborted transaction. Another solution is that, because it sounds like an image is optional, only allow image to ads that have been already been created.[/quote]else what you can do is only move the image file from your temporary location to it's permanent directory once the ad has been placed. so do your advert checking first, insert the details into the database, and if all is well, use move_uploaded_files afterwards.all that needs doing then is an occasional cleanup of your TMP directory.cheers Quote Link to comment 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.