brent123456 Posted October 12, 2007 Share Posted October 12, 2007 I am having trouble trying to get and invalid image. I made a text file then named it test.jpg to test with. I can't seem to find a way to check it i have tried at a lot of test and they fail. I have tried if (getimagesize($_FILES['image']['name'])) { that gives me.. Warning: getimagesize(test.jpg) [function.getimagesize]: failed to open stream: No such file or directory in I have tried checking $_FILES['image']['type'] Could someone help me out please. Link to comment https://forums.phpfreaks.com/topic/72888-trying-to-catch-an-invalid-image-file/ Share on other sites More sharing options...
jimmyyami Posted October 12, 2007 Share Posted October 12, 2007 imagealphablending() you may try to use this function to check the image file, and if the result is FALSE. Most likely the source is not a proper image file. imagealphablending() allows for two different modes of drawing on truecolor images. In blending mode, the alpha channel component of the color supplied to all drawing function, such as imagesetpixel() determines how much of the underlying color should be allowed to shine through. As a result, gd automatically blends the existing color at that point with the drawing color, and stores the result in the image. The resulting pixel is opaque. In non-blending mode, the drawing color is copied literally with its alpha channel information, replacing the destination pixel. Blending mode is not available when drawing on palette images. If blendmode is TRUE, then blending mode is enabled, otherwise disabled. Returns TRUE on success or FALSE on failure. Link to comment https://forums.phpfreaks.com/topic/72888-trying-to-catch-an-invalid-image-file/#findComment-367698 Share on other sites More sharing options...
brent123456 Posted October 12, 2007 Author Share Posted October 12, 2007 Warning: Wrong parameter count for imagealphablending() in C:\myxampp\xampp\htdocs\seedswaps\site_pages\includes\processaddseeds.php on line 133 I tried using the imagealphablending like this and got the warning above. $test = imagealphablending($_FILES['image']['name']); echo $test; I am having a hard time trying to figure this one out. Link to comment https://forums.phpfreaks.com/topic/72888-trying-to-catch-an-invalid-image-file/#findComment-367861 Share on other sites More sharing options...
brent123456 Posted October 12, 2007 Author Share Posted October 12, 2007 I am not sure if this is the correct way but I couldn't find anything that would not check the file and give me a warning error so i just suppressed the error with an '@' before @getimagesize($_FILES['image']['name'] so it will still do the check but not give me a warning and full pass discloser. If anyone knows a better way to handle it I would enjoy hearing it. Thanks Link to comment https://forums.phpfreaks.com/topic/72888-trying-to-catch-an-invalid-image-file/#findComment-367945 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.