Fetch remote posted images and store them locally [barely tested script]
#21
function checkImageFile($imgPath)
{
    $img = getimagesize($imgPath);
    $imageType = $img[2];

    if (in_array($imageType, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP))) {
        return true;
    }
    return false;
}

That's the code I'm using. Surely that should be enough for ensuring it's a valid image type file? I should do something about cleaning up the file names though.
Reply
#22
This user has been denied support. This user has been denied support.
Yes, but I can give you a perfectly valid image file that has perfectly valid PHP code inside of it, which will be perfectly executed by PHP if the file has a .php extension, which seems possible with your code.

You should make the checkImageFile return the extension of the image type it found and then use that extension for your file, and ignore whatever extension was given by the original server.
Reply
#23
Ok, I'll give it a try and work out a better solution. Thanks frostschutz.
Reply
#24
can you tell me how to use this , i really need this to my site
Reply
#25
You can just run the script manually after having uploaded it to your site or via cronjob.
Reply
#26
(2013-06-24, 06:06 PM)Euan T Wrote: You can just run the script manually after having uploaded it to your site or via cronjob.


please tell me moreĀ 
Reply
#27
Upload the script to your forum index. Edit the required lines for your DB configuration then access the file through your browser.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)