echo ' <li> '.mime_content_type($filename).'</li>'
So if $filename = test.php it should give the line item "text/plain". Instead I'm getting an empty line item. Anybody have any idea what I'm doing wrong? Thanks.




Posted 20 July 2009 - 10:26 AM
echo ' <li> '.mime_content_type($filename).'</li>'
Posted 20 July 2009 - 10:49 AM
This post has been edited by RPGonzo: 20 July 2009 - 10:53 AM
Posted 20 July 2009 - 10:49 AM
Posted 20 July 2009 - 11:09 AM
Posted 20 July 2009 - 11:21 AM
SpiderSpartan, on 20 Jul, 2009 - 08:09 PM, said:
Posted 20 July 2009 - 11:37 AM
Posted 20 July 2009 - 12:04 PM
This post has been edited by RPGonzo: 20 July 2009 - 12:04 PM
Posted 20 July 2009 - 12:14 PM
// change myfile to your file ... or you could loop through all files
$file = fopen("myfile","r");
foreach (stream_get_meta_data($file) as $k => $v) {
echo "$k == $v<br/>";
}
This post has been edited by RPGonzo: 20 July 2009 - 12:23 PM
Posted 20 July 2009 - 12:26 PM
This post has been edited by moopet: 20 July 2009 - 12:41 PM
Posted 20 July 2009 - 12:46 PM
Posted 20 July 2009 - 04:12 PM
This post has been edited by SpiderSpartan: 20 July 2009 - 05:46 PM
Posted 20 July 2009 - 07:56 PM
<html>
<H1 ALIGN=CENTER> Movies </H1>
</html>
//Upload code
<form enctype='multipart/form-data' method=post>
<table>
<tr>
<td><input type="file" size="50" name="att[]" class=input></td>
</tr>
</table>
<input class=button type=submit value='Upload'>
<input type="button" value="Return" onclick="window.location.href='/'">
</form>
<?php
// The HTML form handler.
// Uploading all files
for($i = 0; $i < count($_FILES['att']['name']); $i++)
{
// Moving the file from the temporary directory to the
// files subdirectory of the Web application.
if (copy($_FILES['att']['tmp_name'][$i],
"".$_FILES['att']['name'][$i]))
{
// Deleting the file in the temporary directory.
unlink($_FILES['att']['tmp_name'][$i]);
// Changing the file's access permissions
chmod("".$_FILES['att']['name'][$i], 0644);
}
}
// If the superglobal array $_POST is not
// empty, automatically reloading the page.
if(!empty($_POST))
{
echo "<HTML><HEAD>
<META HTTP-EQUIV='Refresh' CONTENT='0; URL=".$_SERVER['PHP_SELF']."'>
</HEAD></HTML>";
}
?>
<?php
//Display the files in this directory
$filearray = scandir(getcwd());
for($loop = 0; $loop < count($filearray); $loop += 1)
{
if(($filearray[$loop] != '..')and($filearray[$loop] != '.')and($filearray[$loop] != 'Index.php')and($filearray[$loop] != 'Uploader.php'))
{
if(substr($filearray[$loop], 0, 1) != '.')
{
If(filetype($filearray[$loop]) == "dir"){
echo ' <li><img src="/icons/folder.gif" alt="[DIR]"><a href="'.$filearray[$loop].'">'.$filearray[$loop]."</a></li>\n";
} elseif(substr(mime_content_type(getcwd()."/".$filearray[$loop]), 0, 4) == "text"){
echo ' <li><img src="/icons/text.gif" alt="[TEXT]"><a href="'.$filearray[$loop].'">'.RemoveExtension($filearray[$loop])."</a></li>\n";
//echo ' <li><a href="'.$filearray[$loop].'">'.mime_content_type(getcwd()."/".$filearray[$loop]).": ".$filearray[$loop].'</a></li>';
}else{
echo ' <li><img src="/icons/unknown.gif" alt="[?]"><a href="'.$filearray[$loop].'">'.RemoveExtension($filearray[$loop])."</a></li>\n";
}
}
}
}
function RemoveExtension($strName)
{
$ext = strrchr($strName, '.');
$ftype = filetype($strName);
if(($ext !== false)and($ftype != "dir"))
{
$fnameChunks = explode(".", $strName);
$strName = $fnameChunks[0];
for($i = 1; $i < count($fnameChunks)-1; $i++)
{
$strName = $strName . "." . $fnameChunks[$i];
}
}
return $strName;
}
?>
This post has been edited by SpiderSpartan: 20 July 2009 - 07:58 PM
Posted 21 July 2009 - 06:07 AM
//Upload code
Posted 21 July 2009 - 07:26 AM
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
