Allow users to insert images securely
Hey all,
Basically I am developing a custom CMS and forum etc. I want to be able to allow users to posts imgs in their signature and posts etc, as many forums and CMS's do. I was wondering if there are any precautions I can take. Also is there any way to stop a user posting a huge image to disfigure everything?
They will be able to post images in the usual BBcode fashion. [img=htt://www.imagelocation.com][/img]
Any help would be greatly appreciated.
Thanks a lot.
S33ker.
mortjony posted this at 04:53 — 31st August 2009.
They have: 2 posts
Joined: Aug 2009
yes you can set image width and height that user can't insert image more than your mentioned width and height and you can also specify image size.
_________________
Rigging Services
Isagenix - Isogenics
S33ker posted this at 17:12 — 31st August 2009.
They have: 38 posts
Joined: Jun 2008
How would that be done then?
So far when a user inserts an image into a posts they click the IMG button and it asks for the image URL. this is then stored in the database as [img=htt://www.imagelocation.com][/img]. When the posts is displayed some PHP transforms the "[img=htt://www.imagelocation.com][/img]" into actual HTML to output the image.
Could I set a class on this image HTML to restrict size? or is there another way to do this?
Thanks,
S33ker.
webwiz posted this at 18:35 — 31st August 2009.
He has: 629 posts
Joined: May 2007
You could also do what Facebook et al do - use PHP to resize the uploaded image. Here's a tutorial on image resizing to get you started: Resize/Thumbnail Images With PHP
Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;
S33ker posted this at 20:50 — 31st August 2009.
They have: 38 posts
Joined: Jun 2008
Found the solution, really simple, did not think it would work.
When then PHP code turns the BBcode [img] into HTML img tag just add a class to the image and attach the following CSS:
.postedImg {
max-width:600px;
max-height:600px;
}
This will then just resize the img to ensure it does not mess up the website layout.
Working Example: http://freed0m.q23.co.uk/viewThread.php?id=33
Thanks everyone!
S33ker.
S33ker posted this at 20:51 — 31st August 2009.
They have: 38 posts
Joined: Jun 2008
Is there a bug report in this forum? Just found one. If I post < i m g then it cuts the post short.
example
There is content after this:
kjim1234 posted this at 03:34 — 1st September 2009.
They have: 1 posts
Joined: Sep 2009
Hi folks.. I am Kim Jaime from Sta. Ana, Manila, Philippines...I am now currently working at ePLDT - Ventus, Jupiter Site as a Customer Service Representative...and as for my personal interest, i am now pretty much interested on web marketing... can anyone help me? thanks...
social media marketing | web marketing
social media marketing | web marketing
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.