I wrote this code to store an image and avoid that someone store a malware or other files different from an image:
$content = file_get_contents($image);
file_put_contents($path, $content);
// Check imagesize to know if it is an image or not:
$sizeimage = getimagesize(dirname(__FILE__)."/".$path);
if($sizeimage[0]<10000){ echo "ok"; }else{ unlink(dirname(__FILE__)."/".$path); }
I tried to insert another files like a CSS file and it store the CSS in the database.
Why ? What is wrong in my code ?