radiations3 Posted August 5, 2011 Share Posted August 5, 2011 I want to know that as we can check the file type while uploading an image or any file just like this.. Can we also check the file type stored in the blob field with the same piece of code and apply conditions on it accordingly? Quote Link to comment https://forums.phpfreaks.com/topic/243900-question-about-a-blob-field/ Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 I do $image = imagecreatefromstring($row['imageBlob']); print getimagesize($image); Quote Link to comment https://forums.phpfreaks.com/topic/243900-question-about-a-blob-field/#findComment-1252388 Share on other sites More sharing options...
radiations3 Posted August 5, 2011 Author Share Posted August 5, 2011 I do $image = imagecreatefromstring($row['imageBlob']); print getimagesize($image); the piece of code that you've shared i think it returns the file size ... I want to know How to return the file type (any builtin function just like getimagesize()??? Quote Link to comment https://forums.phpfreaks.com/topic/243900-question-about-a-blob-field/#findComment-1252392 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 http://php.net/manual/en/function.filetype.php Quote Link to comment https://forums.phpfreaks.com/topic/243900-question-about-a-blob-field/#findComment-1252397 Share on other sites More sharing options...
radiations3 Posted August 5, 2011 Author Share Posted August 5, 2011 suppose if i write echo filetype('$row_Recordset2['file']'); will the above code return the filetype like jpeg,pdf,doc ??? Quote Link to comment https://forums.phpfreaks.com/topic/243900-question-about-a-blob-field/#findComment-1252406 Share on other sites More sharing options...
voip03 Posted August 5, 2011 Share Posted August 5, 2011 $ext = 'anc.jpg'; print end(explode(".", $ext)); Quote Link to comment https://forums.phpfreaks.com/topic/243900-question-about-a-blob-field/#findComment-1252411 Share on other sites More sharing options...
radiations3 Posted August 5, 2011 Author Share Posted August 5, 2011 $ext = 'anc.jpg'; print end(explode(".", $ext)); my question is about returning the file type from the blob field ( where files with different formats saved into the blob fields ).. how to do that. I have saved only images into the blob field and display them from there. if i'll know about returning the filetype from blob field then i may use this field with the files other than images.. Quote Link to comment https://forums.phpfreaks.com/topic/243900-question-about-a-blob-field/#findComment-1252414 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 edit: typing code I believe you need to save the BLOB's content type, as in the FILE when it is being uploaded, then you define the header Content Type Header("Content-type: $contentType") example <?php $sql = "SELECT * FROM `table`"; $result = mysql_query($sql) ; $contentType = $row['contentType']; header("Content-type: $contentType"); $im = imagecreatefromstring($contentType); imagejpeg($im); imagedestroy($im); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/243900-question-about-a-blob-field/#findComment-1252415 Share on other sites More sharing options...
radiations3 Posted August 5, 2011 Author Share Posted August 5, 2011 edit: typing code ?? what to edit Quote Link to comment https://forums.phpfreaks.com/topic/243900-question-about-a-blob-field/#findComment-1252417 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 See post above, you need to save the content type, file type, and other information when your uploading the file. Quote Link to comment https://forums.phpfreaks.com/topic/243900-question-about-a-blob-field/#findComment-1252418 Share on other sites More sharing options...
radiations3 Posted August 5, 2011 Author Share Posted August 5, 2011 See post above, you need to save the content type, file type, and other information when your uploading the file. Hmmmm this is a nice approach for dealing with the file type i can use it... Thanx.... Another issue resolved Thanx ALL!!!! Quote Link to comment https://forums.phpfreaks.com/topic/243900-question-about-a-blob-field/#findComment-1252506 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.