Jump to content


Photo

How should I save images


  • Please log in to reply
2 replies to this topic

#1 soccer022483

soccer022483
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 March 2006 - 03:54 AM

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?

#2 greycap

greycap
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 15 March 2006 - 08:35 AM

[!--quoteo(post=355214:date=Mar 14 2006, 09:54 PM:name=soccer022483)--][div class=\'quotetop\']QUOTE(soccer022483 @ Mar 14 2006, 09:54 PM) View Post[/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.

#3 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 15 March 2006 - 11:07 AM

[!--quoteo(post=355273:date=Mar 15 2006, 08:35 AM:name=greycap)--][div class=\'quotetop\']QUOTE(greycap @ Mar 15 2006, 08:35 AM) View Post[/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

"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users