#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    delhi,india
    Posts
    48
    Rep Power
    4

    Video upload not working


    hi php gurus,
    i am having trouble uploading a video file to a folder i have tried everything found on google but still i cannot upload videos or little large files , i have tried it with other smaller files and the code runs fine
    please advice.

    i have also tried changing the php.ini file
    upload_max_filesize = 100M


    The code
    PHP Code:
    if(isset($_FILES['video'])){
          
    $name $_FILES['video']['name'];
          
    $type explode('.'$name);
          
    $type end($type);
          
    $size $_FILES['video']['size'];
          
    $random_name rand();
          
    $temp $_FILES['video']['tmp_name'];
           
           if(
    $type !='mp4' && $type !='flv' && $type !='mp3' ){
                 
    $msg "not supported";
               echo 
    $msg;
             }else{
                    
    move_uploaded_file($temp,'uploaded_folder/'.$random_name.'.'.$type);
                   }
         } 
    my form
    Code:
    <form enctype="multipart/form-data"  method="POST">
     Please choose a file: <input  type="file"  name="video"/><br />
     <input type="submit" value="Upload" />
     </form>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,350
    Rep Power
    630
    What OS are you using. Some have thier own upload limits. Have you check the httpd logs to see of there are any errors? Have you tried small files to see if they work?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    937
    Rep Power
    280
    I will assume you are only allowing filetypes of .mp4, .flv, or .mp3
    If that is the case, you need to change this
    PHP Code:
    if($type !='mp4' && $type !='flv' && $type !='mp3' 
    to

    PHP Code:
    if($type !='mp4' || $type !='flv' || $type !='mp3' 
    because there is no way that a file extension can be all three of those extensions at the same time [which is what you are asking it to be right now using && ]

    Comments on this post

    • gw1500se disagrees : Please don't ptrovide erroneous answers.
  6. #4
  7. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,436
    Rep Power
    9645
    Originally Posted by DonR
    I will assume you are only allowing filetypes of .mp4, .flv, or .mp3
    If that is the case, you need to change this
    PHP Code:
    if($type !='mp4' && $type !='flv' && $type !='mp3' 
    to

    PHP Code:
    if($type !='mp4' || $type !='flv' || $type !='mp3' 
    because there is no way that a file extension can be all three of those extensions at the same time [which is what you are asking it to be right now using && ]
    So if the type is "mp4" then it will match on the !=flv and be blocked, and if the type is "flv" then it will match on the !=mp4 and be blocked, and then no files at all will be accepted.
    It's right the way it is.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,350
    Rep Power
    630
    The OPs 'if' block is correct. It is a set of negative conditionals. The block will be true when the file type is anything other than the 3 listed types which is exactly what the OP wants. Your conditional would exclude everything.
    Last edited by gw1500se; August 26th, 2014 at 05:30 PM.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    937
    Rep Power
    280
    ah, ok......that makes sense....I don't know what I was thinking
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    delhi,india
    Posts
    48
    Rep Power
    4
    Thanks for ur valuable suggestions . i forgot to make changes on the second php.ini file, now its working fine.

    and sorry for the &&

IMN logo majestic logo threadwatch logo seochat tools logo