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>
2
  • -1 for this mess of code. Missing echo: <?php echo $_SERVER['PHP_SELF']; ?> or <?= $_SERVER['PHP_SELF']; ?> Commented Sep 22, 2014 at 14:50
  • I went ahead and added the echo. Issue still exists. Commented Sep 22, 2014 at 16:17

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Greetings, I own the server and the settings (per cPanel are upload_max_filesize: 50M and all execution times are 300)
What is the memory limit?
memory limit is -1 (no limit)
Not yet. The smallest I have is the 7mb file (these are videos I'm uploading that have to be 1280 x 720). I'll try and find a smaller video.
I can upload the 7mb successfully if I do not check the resolution.
|
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

1 Comment

I added this to the php.ini and double checked file_uploads is on and it is. The issue still exists.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.