Solved

Video Size is limited

Posted on 2010-11-11
2
667 Views
Last Modified: 2013-12-08
I have put a video uploader on my site and it is set to limit videos at 62MB as below.  However, I can upload videos at any size except videos over 8 MB.  What is limiting the size of the video to be uploaded? Is it the server?


$type = explode('.',$_FILES["file"]["name"]);
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
if ((( end($type) == "mpg")
|| (end($type) == "MPG")
|| (end($type) == "mpeg")
|| (end($type) == "MPEG")
|| (end($type) == "wmv")
|| (end($type) == "WMV"))
AND ($_FILES["file"]["size"] < 62000000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
  //  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  //  echo "Type: " . end($type) . "<br />";
  //  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  //  echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

   
      $new_name = time().rand(1,9999999).".".end($type);
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $new_name);
     
      //echo "Stored in: " . "upload/" . $new_name;
       $inserted= "INSERT INTO `ajax_chat_video` (id, filename, title, career, student ) VALUES (
       NULL,
       '".$new_name."',
       '".$_POST[video_title]."',
       '".$_POST[video_career]."',
       '".$_SESSION[id]."'
        )";
      // echo $inserted;
       $just = explode('.',$new_name);
       $sql = @mysql_query($inserted);
       $location = "/home/front/www/chat/upload/";  
       //$location = "upload/";  
       $command = "/usr/local/bin/ffmpeg -i ".$location.$new_name." -deinterlace -ar 44100 -r 25 -qmin 7 -qmax 9 ".$location.$just[0].".flv";
      //     $ffmpeg = exec($command);

$last_line = system($command , $retval);
       
       //echo $last_line.'<br/><br/>'.$retval.'<br/><br/>'.$command.'<br/><br/>';
       
      // $command = "ls -lh";
      // echo exec($command);
       //$command = "ffmpeg -i ".$location.$new_name." -r 1  -t 00:00:10 -f image2 ".$location.$just[0].".png";;
       $command = "/usr/local/bin/ffmpeg -i ".$location.$new_name." -an -ss 00:00:03 -an -r 1 -vframes 1 -y ".$location.$just[0]."%d.jpg";
       $ffmpeg = exec($command);
       
           
       //echo '<br/>'.$command.'<br/>';
       //echo '<br/>'.$ffmpeg.'<br/>';
      echo "The file has been uploaded!";
      }
   
  }else{
  echo "Invalid file, please try again. Type: ".end($type)." | Size: ".$_FILES["file"]["size"];
  }


//echo 'OK OK OK OK OK OK OK OK OK OK ';


?>
</body>
</html>
0
Comment
Question by:Frontstart
  • 2
2 Comments
 
LVL 31

Accepted Solution

by:
Frosty555 earned 500 total points
ID: 34115968
Yes it is your server, it is a PHP thing. These major directives in PHP.INI limit the size of uploads:

MEMORY_LIMIT
POST_MAX_SIZE
UPLOAD_MAX_FILESIZE

The first is the maximum memory that one php session can use - if you upload a file larger than this you will exceed the memory the session can use and it will fail.

The second one is the maximum size of the data in an HTTP form post. Since your form uses HTTP POST to submit the file, this limits the file size. Since the file is usually base64 encoded, this number is actually larger than the real limit - e.g. if it is set to 20MB, your actual real filesize is more like 10-15MB.

Last one is self explainatory
0
 
LVL 31

Expert Comment

by:Frosty555
ID: 34115995
Other things that can cause a large file upload to fail is the IIS/Apache server directly limiting the size of a request header, and also if the script times out before all the data can be uploaded this can also interrupt a file upload and not let it complete.

http://www.radinks.com/upload/config.php

Lots of good info on the subject in the link above.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now