elena wrote:Hi everybody!
I have exactly the same problem
Thread-jacker!! :queasy:
and I've tried both solutions (the image size and mime content type) but unfortunately none of them is working
The image size returns invalid or something like that because it's a .txt file
Well, that was part of laserlight's point. If [man]getimagesize/man returns false, at least you know you aren't dealing with an image (the original poster said he wanted to upload only text files ... so, um, are you sure you have the same problem?
(I changed the .jpg or whatever into .txt manually to cheat) and php can't see it's an image disguised in text file.
Need more information on that; it's certainly not true here.
[292] Fri 21.Apr.2006 7:24:36
[kadmin@archangel][~]
file scan.jpg
scan.jpg: JPEG image data, JFIF standard 1.01
[293] Fri 21.Apr.2006 7:24:39
[kadmin@archangel][~]
php -r "print_r (getimagesize('scan.jpg'));"
Array
(
[0] => 2312
[1] => 2224
[2] => 2
[3] => width="2312" height="2224"
[bits] => 8
[channels] => 3
[mime] => image/jpeg
)
[294] Fri 21.Apr.2006 7:24:48
[kadmin@archangel][~]
mv scan.jpg scan.txt
[295] Fri 21.Apr.2006 7:25:01
[kadmin@archangel][~]
php -r "print_r (getimagesize('scan.txt'));"
Array
(
[0] => 2312
[1] => 2224
[2] => 2
[3] => width="2312" height="2224"
[bits] => 8
[channels] => 3
[mime] => image/jpeg
)
When I tried the mime content type, it keeps on saying it's an unknown function, I also tried an alternative function I found on the php.net:
if ( ! function_exists ( 'mime_content_type ' ) )
{
function mime_content_type ( $f )
{
return system ( trim( 'file -bi ' . escapeshellarg ( $f ) ) ) ;
}
}
but it does nothing
Does it work manually (see above)? You're aware that file is a Nixism, right? AFAIK there's no file(1) on Windows....
I read somewhere I need to change the php.ini settings to get the mime function to work, but (yes there's still one) I don't have access to this file... please help me!!
sigh. 🙁
Really, I'd advise you to start your own thread, probably over in the "newbies" forum. 😉
First, tell us about your exact problem --- what you expect to happen, and what actually happens that is unexpected. Be sure and tell us your operating system and server environment. Run phpinfo() and look for "mime" in the output. Show Us The Code. Find out if "file foo.txt" works from the command line.
Your initial posting here is not bad, but not real auspicious, either. You hijacked a "resolved" thread from 8 months ago, you didn't show code, or really give many details about the problem at all. Try again? 🙂