type = "text/plain"
Moderator: General Moderators
type = "text/plain"
When I upload a text file with IE8, the file fails this test:
if ($_FILES["uploadFile"]["type"] == "text/plain") {
but when I upload the same file with Chrome, Firefox, Opera or Safari, it passes the test.
What's going on here?
Thanks,
JAS
if ($_FILES["uploadFile"]["type"] == "text/plain") {
but when I upload the same file with Chrome, Firefox, Opera or Safari, it passes the test.
What's going on here?
Thanks,
JAS
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: type = "text/plain"
$_FILES["uploadFile"]["type"] is not reliable because it is set by the browser and they may not do it the same way. IE8 probably sets it to application/octet-stream or something. You can use finfo_file() or mime_content_type().
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: type = "text/plain"
I am very new at this. Can you show me the proper syntax for those alternatives (based on the model of what I was using)?
Thanks,
JAS
Thanks,
JAS
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: type = "text/plain"
Look at the manual for more examples:
Code: Select all
$type = mime_content_type($_FILES['uploadFile']['tmp_name']);
//or
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$type = finfo_file($finfo, $_FILES['uploadFile']['tmp_name']);mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: type = "text/plain"
OK. I used the mime_content_type alternative (finfo apparently requires php 5.3.0)
All is well on Chrome, Fifefox, Opera and Safari, but IE8 complains:
Warning: mime_content_type() [function.mime-content-type]: can only process string or stream arguments
That doesn't make any sense to me at all.
Any ideas?
Thanks.
All is well on Chrome, Fifefox, Opera and Safari, but IE8 complains:
Warning: mime_content_type() [function.mime-content-type]: can only process string or stream arguments
That doesn't make any sense to me at all.
Any ideas?
Thanks.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: type = "text/plain"
You shouldn't be using mime_content_type() as it is deprecated. Try the fileinfo alternative (as suggested).
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: type = "text/plain"
This shouldn't have anything to do with the browser. Show the code.jaschulz wrote:OK. I used the mime_content_type alternative (finfo apparently requires php 5.3.0)
All is well on Chrome, Fifefox, Opera and Safari, but IE8 complains:
Warning: mime_content_type() [function.mime-content-type]: can only process string or stream arguments
That doesn't make any sense to me at all.
Any ideas?
Thanks.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: type = "text/plain"
Something is weirdly wrong. Here is my test code:
<?php
$mystring = "mystring = " . $_FILES["uploadFile"]["tmp_name"];
echo $mystring;
?>
It works fine in Chrome etc. But in IE 8 it returns only the constant text (i.e. "my string =") and nothing at all for $_FILES["uploadFile"]["tmp_name"].
My host (bluehost.com) is running php 5.2.1.
Can anyone tell me what's going on here?
<?php
$mystring = "mystring = " . $_FILES["uploadFile"]["tmp_name"];
echo $mystring;
?>
It works fine in Chrome etc. But in IE 8 it returns only the constant text (i.e. "my string =") and nothing at all for $_FILES["uploadFile"]["tmp_name"].
My host (bluehost.com) is running php 5.2.1.
Can anyone tell me what's going on here?
Re: type = "text/plain"
It turns out the problem is in my javascript. I am doing (or trying to do) something fancy to deal with the mess that the different browsers make of the HTML file input, and somehow that is preventing IE from actually sending the name of the file I am trying to upload. I'll try to figure this out tomorrow, and explain it in a new thread.
Thanks.
Thanks.