Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Getting Started / October 2005



Tip: Looking for answers? Try searching our database.

Limiting uploaded image width in user-posted content?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Franklin Cross - 31 Oct 2005 15:54 GMT
I have created a blogging system where users can upload pics to their
galleries then place them into their blogs by way of <img> tags. The problem
is, when the image is over 550 pixels in width, it blows up the tables in
the website. I have already warned them not to put huge images in the blogs
and have limited the filesize, but there is no way to stop people.  Even
posting this warning it in bright red, super large text does not seem to put
a dent it in.

Is there a way to limit the width of an uploaded image?

If not, is there a way to scan for image tags with width greater than 550
and then replace the width attribute?
Noël® - 31 Oct 2005 17:27 GMT
>I have created a blogging system where users can upload pics to their
>galleries then place them into their blogs by way of <img> tags. The
[quoted text clipped - 8 lines]
> If not, is there a way to scan for image tags with width greater than 550
> and then replace the width attribute?

Something like this: (you might will need to set the:
#ExpandPath('#ServerFile#')# )

<!--- :: Get image width and height --->
<cfobject type="JAVA" action="Create" name="tk" class="java.awt.Toolkit">
<cfobject type="JAVA" action="Create" name="img" class="java.awt.Image">
<cfscript>
 img = tk.getDefaultToolkit().getImage("#ExpandPath('#ServerFile#')#");
 Width = img.getWidth();
 Height = img.getHeight();
</cfscript>
<!--- :: Get image width and height :: --->

<cfif Width GT 550>
no no Width is to much!
<cffile action = "delete" file = "#ExpandPath('#ServerFile#')#">
</cfif>

<cfif Height GT 550>
no no Height is to much!
<cffile action = "delete" file = "#ExpandPath('#ServerFile#')#">
</cfif>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.