file detection script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    file detection script

    need the php code..can anyone share?

    #2
    do u mean the file that downloads files for the type file it is so there no errors/ or browser running the file lol

    Comment


      #3
      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;

      ?>

      or
      PHP Code:
      Does $this_file really contain a valid file?

      Do 
      ...


      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


        #4
        maybee external size and type ?
        Code:
        ///$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
        ";

        Comment


          #5
          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


            #6
            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


              #7
              Originally posted by alesh View Post
              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;
                  }

              thats definately incompelete which cant get file extention from a file

              Comment


                #8
                Code:
                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 );

                :D
                Last 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


                  #9
                  Originally posted by rukiya View Post
                  thats definately incompelete which cant get file extention from a file
                  lol you're right

                  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


                    #10
                    Originally posted by rainforest View Post
                    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" />
                    Code:
                     $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

                    Comment


                      #11
                      U want to detect the file ??? I mean detect its size, extension(format) ?

                      Comment

                      Working...
                      X