file detection script
Started on the old forum in March 2009 · view the original in the archive · old links redirect here
Do you want something like this ?
<?
if (!isset($_POST['Submit'])) {
include('html/upload.phtml'); //form to upload
exit;
}
$this_file = $_FILES['file']['tmp_name']; //gets the path to the directory holding the uploaded file
$type = mime_content_type($this_file); //error here
echo "<html>$type</html>";
exit;
?>
or
Does $this_file really contain a valid file?
Do a ...
if (file_exists($this_file))
{
echo "File $this_file exists.";
}
else
{
echo "File $this_file does NOT exist!";
}
left wap stuff
maybee external size and type ?
///$file = "http://somesite.com/files/music.mp3";////example file
$something = get_headers($file, 1);
$size = $something['Content-Length'];
$type = $something['Content-Type'];
echo "<a href=\"$file\">music.$type</a> $size bytes
";
im not sure if u ppl have gt it..im xplaining it..suppose one of our member is gonna upload an mp3 through the uploader..and when the member iz uploading the file i want that file detectn script that will automatically detect the file extnsn and this info will automatically be gone to the database..juz lyk our browser/ip detection or file size codings..now nyone can help?
you could found that in any lava script...
function getextimg($ext)
{
$ext = strtolower($ext);
switch ($ext)
{
case "jar":
case "jad":
return "<img src=\"images/games.gif\" alt=\"igre\"/>";
break;
case "jpg":
case "jpeg":
case "gif":
case "png":
case "bmp":
return "<img src=\"images/image.gif\" alt=\"image\"/>";
break;
case "zip":
case "rar":
return "<img src=\"images/pack.gif\" alt=\"package\"/>";
break;
case "amr":
case "wav":
case "mp3":
case "mid":
return "<img src=\"images/music.gif\" alt=\"music\"/>";
break;
case "mpg":
case "3gp":
case "mp4":
return "<img src=\"images/video.gif\" alt=\"video\"/>";
break;
default:
return "<img src=\"images/other.gif\" alt=\"!\"/>";
break;
}
}
eeeeerrr....
alesh wrote: you could found that in any lava script...
function getextimg($ext) { $ext = strtolower($ext); switch ($ext) { case "jar": case "jad": return "<img src=\"images/games.gif\" alt=\"igre\"/>"; break; case "jpg": case "jpeg": case "gif": case "png": case "bmp": return "<img src=\"images/image.gif\" alt=\"image\"/>"; break; case "zip": case "rar": return "<img src=\"images/pack.gif\" alt=\"package\"/>"; break; case "amr": case "wav": case "mp3": case "mid": return "<img src=\"images/music.gif\" alt=\"music\"/>"; break; case "mpg": case "3gp": case "mp4": return "<img src=\"images/video.gif\" alt=\"video\"/>"; break; default: return "<img src=\"images/other.gif\" alt=\"!\"/>"; break; } }
thats definately incompelete which cant get file extention from a file
function findexts($file)
{
$ufile = strtolower($file) ;
$exts = split("[/\\.]", $file) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
How to use
echo findexts( You file name goes here );
😀
Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!
SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…
rukiya wrote: thats definately incompelete which cant get file extention from a file
lol you're right
its missing
function getext($strfnm)
{
$str = trim($strfnm);
if (strlen($str)<4){
return $str;
}
for($i=strlen($str);$i>0;$i--)
{
$ext .= substr($str,$i,1);
if(strlen($ext)==3)
{
$ext = strrev($ext);
return $ext;
}
}
}
eeeeerrr....
rainforest wrote: im not sure if u ppl have gt it..im xplaining it..suppose one of our member is gonna upload an mp3 through the uploader..and when the member iz uploading the file i want that file detectn script that will automatically detect the file extnsn and this info will automatically be gone to the database..juz lyk our browser/ip detection or file size codings..now nyone can help?
As I understand ur problem, I made this one. NOTE: You can use own variable where I write ['myfile'], it depand on what variable you defined for uploading file. Like : <input type="file" name="myfile" />
$file_name = $_FILES['myfile']['name'];//Return File Name
$file_type = $_FILES["myfile"]["type"];//Return File Type
$file_size = ceil($_FILES["myfile"]["size"] / 1024); //Return File Size in KB
$file_ext = substr($file_name, -3);//Return File extension
/*Now you can send these info into your database when user upload any file*/
Sorry if you could not understand my english lol