need the php code..can anyone share?
file detection script
Collapse
X
-
Do you want something like this ?
PHP Code:<? 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; ?>
orPHP Code: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!"; }Last edited by GiLL; 26.03.09, 13:02.left wap stuff
Comment
-
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?
Comment
-
you could found that in any lava script...
PHP Code: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; } }sigpiceeeeerrr....
Comment
-
thats definately incompelete which cant get file extention from a fileOriginally posted by alesh View Postyou could found that in any lava script...
PHP Code: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; } }
Comment
-
How to useCode:function findexts($file) { $ufile = strtolower($file) ; $exts = split("[/\\.]", $file) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; }
echo findexts( You file name goes here );
:DLast edited by subzero; 29.03.09, 20:40.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...
_______
Info & Tips
php.net
w3schools.com
Comment
-
lol you're rightOriginally posted by rukiya View Postthats definately incompelete which cant get file extention from a file
its missing
PHP Code: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; } } }sigpiceeeeerrr....
Comment
-
Guest
----------------------------------------------------------Originally posted by rainforest View Postim 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" />
Sorry if you could not understand my english lolCode:$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*/
Comment
Comment