Wow. awesome. It works. 
I guess, I should make a list of available dynamically loaded module list 
for GAE PHP Standard environment.

Btw, thanks.




On Wednesday, October 4, 2017 at 8:44:48 PM UTC+6, Yannick (Cloud Platform 
Support) wrote:
>
> The file info extension is available to be dynamically loaded 
> <https://cloud.google.com/appengine/docs/standard/php/runtime#dynamically_loadable_extensions>
>  
> onto App Engine. You should be able to use it once you add the following to 
> your php.ini:
>
> extension = "fileinfo.so"
>
>
> On Wednesday, October 4, 2017 at 10:08:16 AM UTC-4, Shaharia Azam wrote:
>>
>> Hello,
>> Today I am facing a very strange problem while I was just checking 
>> mime-type for uploaded files by my app users in PHP.
>>
>> But it seems, none of the popular PHP functions are working.
>>
>> Here it is I tried already.
>>
>> // Solution # 1
>> $finfo = finfo_open(FILEINFO_MIME_TYPE);
>>         $mtype = finfo_file($finfo, $tmpFile);
>>         finfo_close($finfo);
>>         if ($mtype == ("application/msword") ||
>>             $mtype == 
>> ("application/vnd.openxmlformats-officedocument.wordprocessingml.document") 
>> ||
>>             $mtype == ("application/pdf")
>>         ) {
>>             return true;
>>         } else {
>>             return false;
>>         }
>>
>>
>> //Solution # 2
>>
>> $mimeArray = array(
>>             'application/msword',
>>             
>> 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
>>             'application/pdf'
>>         );
>>         $mime = mime_content_type($tmpFile);
>>         if (!in_array($mime, $mimeArray)) {
>>             return false;
>>         } else {
>>             return true;
>>         }
>>
>>
>>
>> finfo_file, finfo_open, mime_content_type none of these functions are 
>> working. So for PHP application running on GAE standard environment, what's 
>> the most safest and easiest ways to detect file's mime-type in PHP?
>>
>> Thanks in advance.
>>
>>
>> Regards,
>> Shaharia Azam
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/4c101a48-689c-4d04-bfe5-a62d9d600a0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to