FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Failed @getimagesize() print to error_log?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Failed @getimagesize() print to error_log? [message #173089 is a reply to message #173076] Sun, 20 March 2011 22:28 Go to previous messageGo to previous message
jwcarlton is currently offline  jwcarlton
Messages: 76
Registered: December 2010
Karma:
Member
> Tell me, are you taking user input in some form and expecting it to match
> the name of a thumbnail file on the server?
>
> If so, what controls are you placing on that user input to ensure that a
> valid file name is requested?

Not exactly. This section hosts local classifieds, so the user is
uploading it via a Perl script, which verifies that it's a legitimate
image, and renames the image to the ID of the listing (so it's always
a number). Then, the image name is added to a database, which is then
read when a site visitor views the ad.


> Note that the *only* validation that you can rely on is validation
> carried out by the server after the request is received from the viewers
> browser.
>
> Maybe:
>
> <?php
> if (is_set($image) && $image) {
>   $imgFileName = "/home/myaccount/www/thumbs/$image";
>   if (file_exists($imgFileName)) {
>     if (getimagesize($imgFileName)) {
>       // nothing to do here
>     else {
>       $image = "noimage.gif"; // file exists but not an image
>     }
>   } else {
>     $image = "noimage.gif"; // file doesn't exist
>   }} else {
>
>   $image = "noimage.gif"; // $image was not defined or was false}
>
> $height = "75"; // always do this
> ?>
>
> would better meet your needs?

That's a lot more checks than I'm using, so I'll plug that logic in
and see if I keep getting an error. If I am, then that should confirm
that they're not coming from this script.

Thanks,

Jason
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PDO MySQL
Next Topic: Very strange behaviour of imageftbbox()?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 07:04:59 GMT 2024

Total time taken to generate the page: 0.04058 seconds