मैं अगर यह $ छवि चर से किया जा सकता है यकीन है कि नहीं हूँ, लेकिन माइम प्रकार प्राप्त करने के लिए, आप आमतौर पर चार से किसी का उपयोग कर सकते हैं: अपने प्रश्न वर्णन मैं ले आप करना चाहते से
// with GD
$img = getimagesize($path);
return $img['mime'];
// with FileInfo
$fi = new finfo(FILEINFO_MIME);
return $fi->file($path);
// with Exif (returns image constant value)
return exif_imagetype($path)
// deprecated
return mime_content_type($path);
$tmpfname = tempnam("/tmp", "IMG_"); // use any path writable for you
$imageCopy = file_get_contents('http://www.example.com/image.png');
file_put_contents($tmpfname, $imageCopy);
$mimetype = // call any of the above functions on $tmpfname;
unlink($tmpfname);
नोट: इस काम करने के लिए एक दूरस्थ फ़ाइल का उपयोग करें, ताकि आप कुछ इस तरह कर सकता है, तो माइम प्रकार कार्य करते हैं आप का उपयोग करेगा दूरस्थ फ़ाइलों का समर्थन करता है, यह सीधे उपयोग करते हैं, बजाय फ़ाइल की एक प्रतिलिपि बनाने की पहले
यदि आपको माइम टाइप की आवश्यकता है तो यह निर्धारित करने के लिए कि imagecreatefrom
फ़ंक्शन का उपयोग करने के लिए, फ़ाइल को स्ट्रिंग के रूप में पहले लोड क्यों न करें और फिर जीडी निर्णय लें, उदा।
// returns GD image resource of false
$imageString = file_get_contents('http://www.example.com/image.png');
if($imageString !== FALSE) {
$image = imagecreatefromstring($imageString);
}
बात यह है कि आपके कोड पर केवल एक छवि संसाधन पहचानकर्ता उपलब्ध है, इससे कोई फर्क नहीं पड़ता कि मूल वस्तु इस ऑब्जेक्ट के लिए क्या थी। तुम क्यों जानना चाहते हो? – dqhendricks