Irish SEO,  Marketing & Webmaster Discussion

 
Affiliates get Paid On Results, Click Here!

Allowing users to upload images to site

This is a discussion on Allowing users to upload images to site within the Webmaster Discussion forums, part of the Webmaster Help category; Hey everyone just newly registered here after a few months of lurking . I'm just wondering how you all deal ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Webmaster Discussion

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 17-12-2007, 07:29 PM
Frontpage User
 
Join Date: Dec 2007
Posts: 3
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Mr. Pot Noodle will become famous soon enough
Smile Allowing users to upload images to site

Hey everyone just newly registered here after a few months of lurking . I'm just wondering how you all deal with allowing users to upload photos to your site. My main questions being:

How do you stop users uploading incorrect files eg. exe's instead of jpg's etc?
Do you allow them upload it straight to a Db or just the link to it in the Db?
Do you have a function to rename the images so they can be displayed on your site?

Hopefully not a stupid question

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 17-12-2007, 07:31 PM
blacknight's Avatar
Web Slave
 
Join Date: Jan 2006
Location: Ireland
Posts: 6,260
blacknight is a splendid one to beholdblacknight is a splendid one to beholdblacknight is a splendid one to beholdblacknight is a splendid one to beholdblacknight is a splendid one to beholdblacknight is a splendid one to beholdblacknight is a splendid one to behold
Send a message via ICQ to blacknight Send a message via AIM to blacknight Send a message via MSN to blacknight
Default

The first question I'd ask is which technology are you using?

Are you using PHP, Perl, ASP, ASP.net?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 17-12-2007, 07:36 PM
Frontpage User
 
Join Date: Dec 2007
Posts: 3
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Mr. Pot Noodle will become famous soon enough
Default

oops sorry meant to post this at the end........

I'm using PHP with a MySQL Db.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 17-12-2007, 09:59 PM
Forbairt's Avatar
respect my AW-THOR-IT-AYY
 
Join Date: Jun 2007
Location: My Office, Dublin
Posts: 2,016
Nominated 2 Times in 1 Post
Nominated TOTW/F/M Award(s): 1
Forbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enough
Send a message via AIM to Forbairt Send a message via MSN to Forbairt Send a message via Yahoo to Forbairt Send a message via Skype™ to Forbairt
Default

My way ...

writeable directory

1. Check who the user is ... are they allowed to upload ?

2. RTFM (blunt but ... ) PHP: Handling file uploads - Manual it gives you pretty much everything you need to know

3. I don't recommend storing files within the database. The overhead of all that data being read from the database is pretty crazy. It bloats your database it isn't friendly you've got to write scripts to handle files and do a lot of unnecessary crap.

4. Your database should contain a table giving userID, Filename, validated

And away you go ...

store the files outside of your root webfolder preferably if memory serves correctly you want to use fpassthru or similar to grab the files. This is assuming of course the files are "sensitive"


Other steps...
Limit file size they are allowed to upload..
You could try checking the extension of the files they upload.

Then you could try to determine if its an image with the getimagesize function ... if its not .. junk it ... and report the error ...
PHP: getimagesize - Manual

hope thats of some help ...
__________________
Forbairt Media | Web Design & Development Galway / Dublin, Ireland - coming soon ... ( vague but descriptive isn't it )
Recent Work: Safari Club African Safari Holidays - South Africa Safaris
Other Stuff: FluffyLinkulator Rapid Inclusion Service Tools
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 18-12-2007, 03:56 PM
Frontpage User
 
Join Date: Dec 2007
Posts: 3
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Mr. Pot Noodle will become famous soon enough
Default

Cool thanks, just trying to get an idea of the different ways I can do this. Thanks Forbairt.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 18-12-2007, 04:15 PM
Forbairt's Avatar
respect my AW-THOR-IT-AYY
 
Join Date: Jun 2007
Location: My Office, Dublin
Posts: 2,016
Nominated 2 Times in 1 Post
Nominated TOTW/F/M Award(s): 1
Forbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enough
Send a message via AIM to Forbairt Send a message via MSN to Forbairt Send a message via Yahoo to Forbairt Send a message via Skype™ to Forbairt
Default

no problem

depending ... on how important security is ...

you could just upload the files to a directory with a random magic number that you give the user so they can access their file. You can store this name in the database if you want with a reference to the user id ...

Its not secure but guessing the filename could be close to impossible ... you could of course monitor network traffic to see what files are being accessed but that'd be complicated and require a lot more access / knowledge

the method of storing them with a magic number filename or similar would mean you won't have to pass the file through a php script or similar which on a busy site would mean a lot less overhead.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 20-12-2007, 03:22 PM
d-tour's Avatar
Coder
 
Join Date: Apr 2007
Location: Cork
Posts: 82
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
d-tour will become famous soon enough
Default

Quote:
Originally Posted by Forbairt View Post
depending ... on how important security is ...
ya, i got burned a few weeks ago... a malicious file was uploaded to my dir showing all my vulnerabilities
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 20-12-2007, 03:25 PM
Forbairt's Avatar
respect my AW-THOR-IT-AYY
 
Join Date: Jun 2007
Location: My Office, Dublin
Posts: 2,016
Nominated 2 Times in 1 Post
Nominated TOTW/F/M Award(s): 1
Forbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enough
Send a message via AIM to Forbairt Send a message via MSN to Forbairt Send a message via Yahoo to Forbairt Send a message via Skype™ to Forbairt
Default

Quote:
Originally Posted by d-tour View Post
ya, i got burned a few weeks ago... a malicious file was uploaded to my dir showing all my vulnerabilities

ouchies

Windows or Linux system ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 20-12-2007, 03:32 PM
d-tour's Avatar
Coder
 
Join Date: Apr 2007
Location: Cork
Posts: 82
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
d-tour will become famous soon enough
Default

unix
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 20-12-2007, 03:40 PM
Forbairt's Avatar
respect my AW-THOR-IT-AYY
 
Join Date: Jun 2007
Location: My Office, Dublin
Posts: 2,016
Nominated 2 Times in 1 Post
Nominated TOTW/F/M Award(s): 1
Forbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enough
Send a message via AIM to Forbairt Send a message via MSN to Forbairt Send a message via Yahoo to Forbairt Send a message via Skype™ to Forbairt
Default

damn ... ... uploaded a php file or something like that ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
allowing, images, site, upload, users

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Successful Site in 12 Months with Google Alone montyauto Webmaster Articles 11 18-02-2008 12:28 PM
Google Images - Display Method - How is it done? davidbehan Coding Help 10 12-01-2007 04:09 PM
The Million Dollar Homepage tomed Online Marketing Discussion 22 31-01-2006 08:47 PM


All times are GMT +1. The time now is 04:06 PM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0