Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test Forum

Home » Forum » x-Forum » Question

how to set limit for video file size upload

Hi, i have a webapp that allows users to upload video to server for sharing, but inorder to minimize storage usage i want to set a limi to video file size upload per user.
But when i added a code snippet for the modification after saving and refreshing the page it goes blank i.e it does not show anything on the UI for uploading.
See the code below


if ($_POST['video_type']=='local')
        {

              $maxsize = 5242880; // 5MB
              
              // Check file size
            if(($_FILES['file']['size'] >= $maxsize) || ($_FILES["file"]["size"] == 0)) {
            echo "File too large. File must be less than 5MB.";
          }else{
            // Upload
            $file_path = 'http://'.$_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']).'/uploads/';
              echo "Upload successfully.";
            }
          }
              
           /*   $file_path = 'http://'.$_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']).'/uploads/';   */
              
              $video_url=$file_path.$_POST['video_file_name'];

              $file_name= str_replace(" ","-",$_FILES['video_thumbnail']['name']);

              $video_thumbnail=rand(0,99999)."_".$file_name;
       
              //Main Image
              $tpath1='images/'.$video_thumbnail;        
              $pic1=compress_image($_FILES["video_thumbnail"]["tmp_name"], $tpath1, 80);
         
              //Thumb Image 
              $thumbpath='images/thumbs/'.$video_thumbnail;   
              $thumb_pic1=create_thumb_image($tpath1,$thumbpath,'200','200');   

              $video_id='';
        }

Kindly help		

Posted by joakins 2019-04-12 10:48:28

No Ans Posted

Please login to comment

Log In


Ask New Question