1

I'm having an issue with a file upload where it's not uploading. When uploading a 7mb video the $_FILES['video']['tmp_name'] is empty and when I upload a 15mb file the form doesn't actually "submit", really just refreshes.

Here is my code to handle the submission:

if(isset($_POST['submit'])){

    $blah = "".$_FILES['video']['size']."";
    var_dump($blah);

    if( empty($_FILES['video']) && empty($_POST['create_video']) ){
        echo "<div class='alert alert-danger' role='alert'><center><strong>Missing Fields:</strong> Please choose a video or request the ##### team create a video.</center></div>";
    } else {

        if( empty($_FILES['video']['name']) && $_POST['create_video'] == "true" ){
            $_SESSION['create_video'] = protect($_POST['create_video']);
            ?>
                <script type="text/javascript">
                    window.location = "NEXT_PAGE";
                </script>
            <?

                exit();

        }else{

            //if all were filled in continue
            $allowedExts = array("mp4", "MP4", "m4a");
            $extension = pathinfo($_FILES['video']['name'], PATHINFO_EXTENSION);

            if ( ($_FILES["video"]["size"] <= 15728640) && (in_array($extension, $allowedExts)) ) {

                if ($_FILES["video"]["error"] > 0){
                    echo "Return Code: " . $_FILES["video"]["error"] . "<br />";
                }else{
                    //Get the height and width of our video
                    //$getID3 = new getID3;
                    //$file = $getID3->analyze($_FILES["video"]["tmp_name"]);
                    //$width =$file['video']['resolution_x'];
                    //$height = $file['video']['resolution_y'];
                    $img = getimagesize($_FILES['video']['tmp_name']);
                    $width = $img[0];
                    $height = $img[1];
                    var_dump($width); var_dump($height);
                    if( ($height < 719) || ($width < 1279)){
                        echo "<div class='alert alert-danger' role='alert'><center><strong>Invalid file dimensions</strong> Please ensure your image is the correct size.</center></div>";

                    } else {

                        $ext = findexts ($_FILES["video"]["name"]);
                        $ran = rand ();
                        $file_name = $_FILES["video"]["name"] = "".$_SESSION['uid'] ."".$ran.".".$ext."";

                            if (file_exists("uploads/video_ads/".$_SESSION['uid']."_" . $_FILES["video"]["name"])){
                                echo $_FILES["video"]["name"] . " already exists. ";
                            }else{
                                move_uploaded_file($_FILES["video"]["tmp_name"],
                                "uploads/video_ads/".$_SESSION['uid']."_" . $_FILES["video"]["name"]);

                            //Save the link of our ad
                            $_SESSION['video'] = "####/uploads/video_ads/".$_SESSION['uid']."_" . $_FILES["video"]["name"]."";
                            $_SESSION['create_video'] = protect($_POST['create_video']);

                            ?>
                                <script type="text/javascript">
                                    window.location = "NEXT_PAGE";
                                </script>
                            <?
                            exit();

                            }
                    }
                }
            } else {
                echo "<div class='alert alert-danger' role='alert'><center><strong>Invalid file type</strong> Please upload a video in MP4 format.</center></div>";
            }
        }
    }
}

Here is my actual form:

<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" class="form-signin" role="form" enctype="multipart/form-data">
                    <br />
                    <input type="file" name="video" id="video" /><br />
                    <br />


                    <div class="row">
                        <div class="col-md-12">
                            <strong class="ad-header"
                                style="font-size: 150%; font-weight: bold;">Quick Tips:</strong>
                        </div>

                    </div>
                    <hr>
                    <h3 class="ad-sub-header" style="color: #559fd3; font-size: 150%;">Need
                        help to create engaging artwork for your brand?</h3>
                    <strong class="ad-header" style="font-size: 100%;">####
                        has the creative team to get it done for you</strong><br /> Only ##/hr -
                    3 revisions - Artwork is yours to keep. <br />
                    <br /> <input type="checkbox" name="create_video" value="true" />
                    I don't have an ad. Please create one. <br />
                    <br /> <input class="btn btn-lg btn-primary btn-block"
                        type="submit" name="submit" value="Continue To Step 5" />
                </form>
user1890328
  • 1,222
  • 1
  • 13
  • 21

3 Answers3

2

The odds are your server does not accept uploads greater than 2M in size. You need to check phpinfo() (or php.ini if you have access to it) to see what your current limit is. If it is only 2M, or smaller than your upload size, you need to edit it to allow for bigger uploads. If you're on shared hosting you may be out of luck.

John Conde
  • 217,595
  • 99
  • 455
  • 496
0

Try adjusting your php.ini with this settings:

php_value memory_limit 96M
php_value post_max_size 96M
php_value upload_max_filesize 96M

and ensure that the file_uploads setting is in On

ignaciotr
  • 198
  • 4
  • 14
0

For anyone who has this issue. I had to increase my post_max_size which was defaultly set to 8M.

user1890328
  • 1,222
  • 1
  • 13
  • 21